I have been trying to find an answer to this question and have not been
to. Any help is greatly appreciated.
I am using Rails 2.1.0 and Rspec 1.1.4.
How can I set an instance variable in my Rspec test that is then
to my controller while the test is running? For example:
(I tried to keep this as simple as possible while illustrating what I
@user = User.find( 5 )
render :action => ‘cart_full’
render :action => ‘cart_empty’
describe CartController do
describe “index” do
it "should render 'cart_full' if @user is set" do # This is where I need to set @user response.should render_template( : cart_full ) end it "should render 'cart_empty' if @user is not set" do response.should render_template( : cart_empty ) end
Is this even possible to do?
I thought that controller.set_instance_variable( :@user, … ) would do
trick but it does not seem to work.
View this message in context:
Sent from the rspec-users mailing list archive at Nabble.com.