rspec/rspec-mocks — Issue #103: should_receive'ing a stub'ed method does not work properly
Author: FooBarWidget
Created: 2012-02-02 17:29:28+00:00
State: open

Test case:

describe "should_receive" do
it "works properly on stubbed methods" do
user = mock
user_class = Object.new
user_class.stub!(:find).and_return(nil)
user_class.should_receive(:find).at_least(:once).and_return(user)
user_class.find(1).should == user
user_class.find(1).should == user
user_class.find(1).should == user
end
end

The user_class `stub!` call screws up the the `should_receive` call. I expect `user_class.find(1)` to return `user` every time, but what actually happens is that it returns `nil` after the first call.