class ConcernTest
Public Instance Methods
setup()
click to toggle source
# File activesupport/test/concern_test.rb, line 64 def setup @klass = Class.new end
test()
click to toggle source
# File activesupport/test/concern_test.rb, line 89 def test end
test_class_methods_are_extended()
click to toggle source
# File activesupport/test/concern_test.rb, line 74 def test_class_methods_are_extended @klass.include(Baz) assert_equal "baz", @klass.baz assert_equal ConcernTest::Baz::ClassMethods, (class << @klass; included_modules; end)[0] end
test_class_methods_are_extended_only_on_expected_objects()
click to toggle source
# File activesupport/test/concern_test.rb, line 80 def test_class_methods_are_extended_only_on_expected_objects ::Object.include(Qux) Object.extend(Qux::ClassMethods) # module needs to be created after Qux is included in Object or bug won't # be triggered test_module = Module.new do extend ActiveSupport::Concern class_methods do def test end end end @klass.include test_module assert_equal false, Object.respond_to?(:test) Qux.class_eval do remove_const :ClassMethods end end
test_dependencies_with_multiple_modules()
click to toggle source
# File activesupport/test/concern_test.rb, line 113 def test_dependencies_with_multiple_modules @klass.include(Foo) assert_equal [ConcernTest::Foo, ConcernTest::Bar, ConcernTest::Baz], @klass.included_modules[0..2] end
test_included_block_is_ran()
click to toggle source
# File activesupport/test/concern_test.rb, line 100 def test_included_block_is_ran @klass.include(Baz) assert_equal true, @klass.included_ran end
test_module_is_included_normally()
click to toggle source
# File activesupport/test/concern_test.rb, line 68 def test_module_is_included_normally @klass.include(Baz) assert_equal "baz", @klass.new.baz assert_includes @klass.included_modules, ConcernTest::Baz end
test_modules_dependencies_are_met()
click to toggle source
# File activesupport/test/concern_test.rb, line 105 def test_modules_dependencies_are_met @klass.include(Bar) assert_equal "bar", @klass.new.bar assert_equal "bar+baz", @klass.new.baz assert_equal "bar's baz + baz", @klass.baz assert_includes @klass.included_modules, ConcernTest::Bar end
test_raise_on_multiple_included_calls()
click to toggle source
# File activesupport/test/concern_test.rb, line 118 def test_raise_on_multiple_included_calls assert_raises(ActiveSupport::Concern::MultipleIncludedBlocks) do Module.new do extend ActiveSupport::Concern included do end included do end end end end