You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
I encountered a weird issue with 2.6.0.rc2 where I was stubbing a method on any_instance of a model. In the model specs (which were run after the controller specs) my tests were showing that the method was undefined.
from builds_controller_spec.rb:
beforedoBuild.any_instance.stub(:already_built?).and_return(false)endit"should not create any builds when both builds already exist"doBuild.any_instance.stub(:already_built?).and_return(true)post:create,:build=>{:slot=>'something'}Build.count.should == 0end
from build_spec.rb:
it{shouldrespond_to:already_built?}
If I run the controller spec first, I see this:
Failure/Error: it { should respond_to :already_built? }
expected #<Build id: nil ...> to respond to :already_built?
If I run the tests in the opposite order, everything is fine. I've narrowed the cause down to the specific any_instance line in the controller spec because if I comment out that one line, all of the other tests pass.
My assumption is that because I'm stubbing the same method on any_instance twice, it actually deletes the real method when cleaning up the 2nd time after the spec block.