| Class | CoreEx::Module::TestMixInWithArgs |
| In: |
lib/core_ex/module/mix_in_with_args.rb
|
| Parent: | ::Test::Unit::TestCase |
| MOCK_OBJECT | = | Mocks::Object.new |
# File lib/core_ex/module/mix_in_with_args.rb, line 162 def setup @module = Class.new @mock_object = MOCK_OBJECT end
# File lib/core_ex/module/mix_in_with_args.rb, line 245 def test_already_tagged @module = WithTag assert_nothing_raised { @module.new.tag } assert_mixin Taggable assert_nothing_raised { @module.new.tag } assert_mock_calls [[:old_tag], [:setup], [:tag_defined, true], [:tag_defined, false], [:self_is=, @module], [:teardown], [:tag_defined, true], [:tag]] end
# File lib/core_ex/module/mix_in_with_args.rb, line 171 def test_cleanable assert_mixin Cleanable assert_empty_mock assert_nothing_raised { @module.new.clean(:foo, 42) } assert_mock_calls [[:clean, [:foo, 42]]] end
# File lib/core_ex/module/mix_in_with_args.rb, line 196 def test_setup_fixed_args assert_mixin SetupFixedArgs, [1, 2, 3] assert_nothing_raised { @module.new } assert_mock_calls [[:setup, [1, 2, 3]], [:self_is=, @module]] end
# File lib/core_ex/module/mix_in_with_args.rb, line 190 def test_setup_without_args assert_mixin SetupWithoutArgs assert_nothing_raised { @module.new } assert_mock_calls [[:self_is=, @module]] end
# File lib/core_ex/module/mix_in_with_args.rb, line 178 def test_taggable assert_mixin Taggable, [:foo => :bar] assert_nothing_raised { @module.new.tag(:foo, 42) } assert_mock_calls [[:setup, {:foo => :bar}], [:tag_defined, false], [:tag_defined, false], [:self_is=, @module], [:teardown, {:foo => :bar}], [:tag_defined, true], [:tag, [:foo, 42]]] end
# File lib/core_ex/module/mix_in_with_args.rb, line 235 def test_with_class_methods assert_mixin WithClassMethods assert_nothing_raised do @object = @module.new @object.i @module.m end assert_mock_calls [[:setup, @module], [:i, @object], [:m, @module]] end
# File lib/core_ex/module/mix_in_with_args.rb, line 202 def test_with_include m = ::Module.new m.module_eval " class A include Taggable end class B include Cleanable end class C mixin SetupFixedArgs, 1, 2, 3 include SetupWithoutArgs end " assert_nothing_raised do @a, @b, @c = m::A.new, m::B.new, m::C.new @a.tag @b.clean end assert_mock_calls [ [:setup], [:tag_defined, false], [:tag_defined, false], [:self_is=, m::A], [:teardown], [:tag_defined, true], [:setup, [1, 2, 3]], [:self_is=, m::C], [:self_is=, m::C], [:tag], [:clean] ] end