[rspec-users] Can NOT overides the stub! in the setup

bruce zuo brucezuo at gmail.com
Mon Sep 10 22:47:50 EDT 2007


Hello,

I am new to rSpec. I tried to search in the list, but could not find
the answer, please forgive me if somebody already answered this. Here
is my question:

I have a stub in setup:

  before(:each) do
    @current_user = mock("devsu")
    # Generally, prefer stub! over should_receive in setup.
    User.stub!(:find).and_return(@current_user)
    session[:user] = @current_user.id
  end
Where User is a model.

Then I tried to overrides it within a spec in a rails CONTROLLER specs:
  it "descriptions...." do
     ...
     User.should_receive(:find).with("3").and_return(mock_user)
     get 'show', :id => 3
  end

I found only '3', that is right, only single quotes can overrides the
stub! in setup, the "3", double quotes won't work. I am wondering if
this is the way how it works?

Thanks.

--Bruce


More information about the rspec-users mailing list