Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

should_receive_and_execute: support multiple expectations on the same…

… method
  • Loading branch information...
commit d998f57cc22fee2115822d2f98876c9fb217cf80 1 parent 09daf02
@kratob kratob authored
View
4 lib/rspec_candy/helpers/should_receive_and_execute.rb
@@ -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
- define_method method_called do |*args|
+ unless method_defined?(method_called)
+ define_method method_called do |*args|
+ end
end
if method_defined_directly
View
8 spec/shared/rspec_candy/helpers/should_receive_and_execute_spec.rb
@@ -48,6 +48,14 @@ def method_missing(symbol, *args, &block)
object.foo.should == 'foo'
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
Please sign in to comment.
Something went wrong with that request. Please try again.