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
David Chelimsky
2007-Sep-11 02:52 UTC
[rspec-users] Can NOT overides the stub! in the setup
On 9/10/07, bruce zuo <brucezuo at gmail.com> wrote:> 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?What''s the error that you get when you use double quotes?> > Thanks. > > --Bruce > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >