I'm looking at an example where a stub seems to work sometimes, and sometimes appears to become "unstubbed". I haven't boiled it down to a minimal example, but it goes something like this: ---- the model: class Premise << ActiveRecord::Base def lookup_stuff_on_the_web $stderr.puts("entering lookup_stuff_on_the_web with #{self}") ... end end ---- the rspec test file: describe Analysis do before(:each) do @premise = Factory(:premise) @premise.stub(:lookup_things_on_the_web) $stderr.puts("just stubbed #{@premise.inspect}") end
it "should not hit the web" do @premise.lookup_things_on_the_web.should_not raise_exception end end ---- When I run the test, I see: just stubbed #<Premise id: 1, user_id: 1, ...> entering lookup_stuff_on_the_web with #<Premise id: 1, user_id: 1, ...> Failure/Error: ... WebMock::NetConnectNotAllowedError: As far as I can see, the Premise that's being stubbed and the Premise whose lookup_stuff_on_the_web method is getting called are one and the same. What I can't figure out is why the stub isn't being honored. (FWIW, the same setup code is working in other tests.) Are there any known gotchas I should be looking for? Or specific things I should try to uncover the cause? TIA. - ff -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users