Browse files

Added spec demonstrating mock return value for an edge case.

When a method has been stubbed previously to return a certain value (say, in a before(:each)), and then mocked w/o a return value (say, in a spec, to ensure a method was called), the stubbed value should still be returned.
  • Loading branch information...
1 parent 361f315 commit b8135d5d8d04930f09d606a96c2d84be910a12f2 @myronmarston myronmarston committed with dchelimsky Oct 9, 2010
Showing with 8 additions and 1 deletion.
  1. +8 −1 spec/rspec/mocks/mock_spec.rb
@@ -88,7 +88,14 @@ module Mocks
- it "returns nil if no return value set" do
+ it "returns the previously stubbed value if no return value is set" do
+ @mock.stub!(:something).with("a","b","c").and_return(:stubbed_value)
+ @mock.should_receive(:something).with("a","b","c")
+ @mock.something("a","b","c").should == :stubbed_value
+ @mock.rspec_verify
+ end
+ it "returns nil if no return value is set and there is no previously stubbed value" do
@mock.something("a","b","c").should be_nil

0 comments on commit b8135d5

Please sign in to comment.