Rspec Messes Up Stubs and Expectations

Here is an example showing the issue :

1
2
3
4
5
6
7
8
9
before :each do
  @car = stub("a car")
  @car.stub(:move)
end
it "should be possible to mix stubbing and expectations" do
  @car.should_receive(:move).once

  2.times { @car.move }
end

This example should obviously fail, but it passes ! Here is a working (failing) version :

1
2
3
4
5
6
7
8
before :each do
  @car = stub("a car")
 end
it "should be possible to mix stubbing and expectations" do
  @car.should_receive(:move).once

  2.times { @car.move }
end

I am using rspec 1.3.0. Did you fall into the same issues ? Is this fixed in rspec 2 ?

Comments