[rspec-users] Access to controller and request objects in controller specs (rails 3)

stevehodgkiss steve at hodgkiss.me.uk
Fri Mar 12 10:44:24 EST 2010


Rails 3 provides @controller and @request as instance variables in
controller tests, whats the equivalent in rspec controller tests?

I'm using warden for authentication and need to be able to stub
@request.env['warden'] with something so that controllers can be
tested. Currently @request is nil (error: undefined method `env' for

If I remember correctly the default controller specs in rails 2/rspec
1 contained this assertion:

controller.should be_an_instance_of(MyController)

This fails with rails 3/rspec 2 beta 3 because controller is nil.

Any ideas?



More information about the rspec-users mailing list