[rspec-users] Stub conflict?

Justin Ko jko170 at gmail.com
Fri Apr 6 18:31:04 UTC 2012


On Apr 5, 2012, at 6:03 PM, James wrote:

> Hi,
> I have two stubs in two different specs (one model, one controller).
> For some reason they are causing some strange conflict with one
> another.
> If I comment out the controller stub, the model spec passes.
> 
> Controller Spec
> -----------------------------------
> require 'spec_helper'
> describe MyClass::SomeController do
>    it 'should do stuff' do
>      Some::Base.stub!(:mystub)   #IF I COMMENT THIS OUT IT PASSES
>    end
> end
> 
> 
> I have this line in another model spec
> ------------------------------------------------------

Oh, and if you want to keep things the way they are, try add this line right before mocking Some::Thing:

Some::Thing.rspec_reset

>    Some::Thing.should_receive(:mystub).exactly(4).times.and_return
> nil
> 
> 
> 'Thing' is a child class of 'Base'.
> 
> Here is the error:
> ----------------------------
>     Failure/Error:
> Some::Thing.should_receive(:mystub).exactly(4).times.and_return nil
>       (<Some::Thing (class)>).mystub(any args)
>           expected: 4 times
>           received: 2 times
> 
> 
> 
>  * rspec (2.9.0)
>  * rspec-core (2.9.0)
>  * rspec-expectations (2.9.0)
>  * rspec-mocks (2.9.0)
>  * rspec-rails (2.9.0)
> rails (3.0.4)
> ruby 1.8.7
> 
> Thanks in advance!
> 
> James
> 
> 
> 
> 
> 
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list