Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-mocks
...
head fork: rspec/rspec-mocks
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 17, 2012
@myronmarston myronmarston Fix a regression.
When doing something like:

  double.stub(:foo).and_return(a, b)
  double.should_receive(:foo).once { a }
  double.foo

...it used to work, but in 2.10 it raises a NoMethodError (#size).
132f99c
View
10 lib/rspec/mocks/message_expectation.rb
@@ -34,7 +34,15 @@ def initialize(error_generator, expectation_ordering, expected_from, message, ex
def build_child(expected_from, expected_received_count, opts={}, &implementation)
child = clone
child.expected_from = expected_from
- child.implementation = implementation if implementation
+
+ if implementation
+ child.implementation = implementation
+
+ # A new block implementation is given, so the old multi-return
+ # implementation needs to be disabled
+ child.instance_variable_set(:@consecutive, false)
+ end
+
child.expected_received_count = expected_received_count
child.clear_actual_received_count!
new_gen = error_generator.clone
View
8 spec/rspec/mocks/block_return_value_spec.rb
@@ -7,6 +7,14 @@
obj.should_receive(:foo) { 'bar' }
obj.foo.should eq('bar')
end
+
+ it "works when a multi-return stub has already been set" do
+ obj = Object.new
+ return_value = Object.new
+ obj.stub(:foo).and_return(return_value, nil)
+ obj.should_receive(:foo) { return_value }
+ obj.foo.should be(return_value)
+ end
end
describe "stub" do

No commit comments for this range

Something went wrong with that request. Please try again.