Permalink
Browse files

Use pure doubles (Mock.new) in the middle of stub_chain

- was using Object.new
- Fixes #587
  • Loading branch information...
dchelimsky committed Aug 16, 2012
1 parent 39ae1f3 commit 05741e90083280c1b9e069350d7e3afbf4a45456
Showing with 6 additions and 1 deletion.
  1. +1 −1 lib/rspec/mocks/methods.rb
  2. +5 −0 spec/rspec/mocks/stub_chain_spec.rb
@@ -84,7 +84,7 @@ def stub_chain(*chain, &blk)
chain.shift
matching_stub.invoke.stub_chain(*chain, &blk)
else
- next_in_chain = Object.new
+ next_in_chain = Mock.new
stub(chain.shift) { next_in_chain }
next_in_chain.stub_chain(*chain, &blk)
end
@@ -144,6 +144,11 @@ module Mocks
object.msg1.msg2.msg3.msg4.should equal(:first)
object.msg1.msg2.msg3.msg5.should equal(:second)
end
+
+ it "handles private instance methods (like Object#select) in the middle of a chain" do
+ object.stub_chain(:msg1, :select, :msg3 => 'answer')
+ expect(object.msg1.select.msg3).to eq 'answer'
+ end
end
end
end

0 comments on commit 05741e9

Please sign in to comment.