[rspec-users] Getting to the session from Stories

David Chelimsky dchelimsky at gmail.com
Sat Apr 5 23:00:56 EDT 2008

On Sat, Apr 5, 2008 at 9:55 PM, Mikel Lindsaar <raasdnil at gmail.com> wrote:
> Hey all,
>  In a story I want to say
>  Given "A logged in user" do
>   sesson[:logged_in] = true
>   etc...
>  end
>  But the session method doesn't have anything to bind to, I get the
>  error '... while evaluating nil.session...'
>  Any ideas?

This is not supported by Rails' ActionController::IntegrationTest,
from which RailsStory is derived.

The intention of ActionController::IntegrationTest is to provide an
environment for testing through routers. What you're trying to do is
really the domain of RSpec controller specs or Rails functional tests.

What I'd recommend is that you actually log in and go from there:

>  The fact that the user is logged in or not, doesn't matter to this
>  story, so I just want to stub it out.

Stubbing in stories should be avoided except for stubbing external services.


>  The other way is stubbing out all the authentication methods, but that
>  is more typing :)  (less than this message to find out how to do it
>  the short way, but you know, once you think you need to do something,
>  doing it the longer way just seems wrong :D
>  Regards
>  Mikel
>  _______________________________________________
>  rspec-users mailing list
>  rspec-users at rubyforge.org
>  http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list