Skip to content

Commit af6cc00

Browse files
committed
Invoke blocks in class methods.
Continuation of a4944af for class methods. Pair: Adam Martin/Magnus Stahre
1 parent ce0c71c commit af6cc00

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/gimme/gives_class_methods.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def method_missing(method, *args, &block)
1717

1818
#TODO this will be redundantly overwritten
1919
meta_class.instance_eval do
20-
define_method method do |*actual_args|
20+
define_method method do |*actual_args, &actual_block|
2121
Gimme.invocations.increment(cls, method, actual_args)
22-
InvokesSatisfiedStubbing.new(cls).invoke(method, actual_args)
22+
InvokesSatisfiedStubbing.new(cls).invoke(method, actual_args, actual_block)
2323
end
2424
end
2525

spec/gimme/gives_class_methods_spec.rb

+14
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,19 @@ def self.eat(food)
4747
Given(:gives) { give!(subject) }
4848
end
4949
end
50+
51+
context "when called with a block" do
52+
Given do
53+
give(Rabbit).eat {|blk| blk.call }
54+
end
55+
56+
57+
Then do
58+
obj_in_block = false
59+
Rabbit.eat { obj_in_block = true }
60+
obj_in_block.should be_true
61+
end
62+
end
63+
5064
end
5165
end

0 commit comments

Comments
 (0)