Skip to content

Commit

Permalink
should_receive_and_execute: support multiple expectations on the same…
Browse files Browse the repository at this point in the history
… method
  • Loading branch information
kraatob committed Mar 18, 2013
1 parent 09daf02 commit d998f57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rspec_candy/helpers/should_receive_and_execute.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def should_receive_and_execute(method)


method_defined_directly = method_defined?(method) || private_method_defined?(method) # check that a method is not "defined" by responding to method_missing method_defined_directly = method_defined?(method) || private_method_defined?(method) # check that a method is not "defined" by responding to method_missing


define_method method_called do |*args| unless method_defined?(method_called)
define_method method_called do |*args|
end
end end


if method_defined_directly if method_defined_directly
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def method_missing(symbol, *args, &block)
object.foo.should == 'foo' object.foo.should == 'foo'
end end


it 'should work when setting multiple expectations on the same method' do
object = "16"
object.should_receive_and_execute(:to_i).with(10)
object.should_receive_and_execute(:to_i).with(8)
object.to_i(10).should == 16
object.to_i(8).should == 14
end

end end


end end
Expand Down

0 comments on commit d998f57

Please sign in to comment.