test/unit/much-mixin_tests.rb in much-mixin-0.2.3 vs test/unit/much-mixin_tests.rb in much-mixin-0.2.4
- old
+ new
@@ -12,11 +12,12 @@
@muchmixin = Module.new{ include MuchMixin }
end
subject{ @muchmixin }
- should have_imeths :much_mixin_included_detector, :much_mixin_included_blocks
+ should have_imeths :much_mixin_included_detector
+ should have_imeths :much_mixin_included_blocks
should have_imeths :mixin_included, :after_mixin_included
should "know its included detector" do
mixin = subject.much_mixin_included_detector
assert_instance_of Module, mixin
@@ -41,16 +42,31 @@
class MixedInTests < UnitTests
desc "when mixed in"
setup do
@receiver = Class.new do
- def self.inc_block1; @block1_count ||= 0; @block1_count += 1; end
- def self.block1_count; @block1_count ||= 0; end
- def self.inc_block2; @block2_count ||= 0; @block2_count += 1; end
- def self.block2_count; @block2_count ||= 0; end
+ def self.inc_block1
+ @block1_count ||= 0
+ @block1_count += 1
+ end
- def self.do_something_count; @do_something_count ||= 0; end
+ def self.block1_count
+ @block1_count ||= 0
+ end
+
+ def self.inc_block2
+ @block2_count ||= 0
+ @block2_count += 1
+ end
+
+ def self.block2_count
+ @block2_count ||= 0
+ end
+
+ def self.do_something_count
+ @do_something_count ||= 0
+ end
end
end
should "call the mix-in included blocks" do
assert_equal 0, @receiver.block1_count
@@ -107,13 +123,13 @@
TestMuchMixin =
Module.new do
include MuchMixin
mixin_included{ inc_block1 }
- after_mixin_included{
+ after_mixin_included do
inc_block2
do_something
- }
+ end
mixin_class_methods do
def do_something
@do_something_count ||= 0
@do_something_count += 1