If it is a normal controller or non-Webkit test, you can access the controller variable directly (I think with @controller), so you can just set session vars directly like:
@controller.session[:current_user] = @my_user If you are writing a capybara webkit test, you don't have direct access to the same ruby environment where the session runs, but you can use this excellent gem to access it: https://github.com/railsware/rack_session_access If you're using devise, there's patterns for doing this both in and out of webkit. Checkout this for an explanation: https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara > On Dec 4, 2014, at 1:52 AM, bertly_the_coder <[email protected]> wrote: > > Hi Guys, > > I'm writing some controller tests in rspec and one of them needs a session to > be set. Does anyone know how to set a session in rails tests? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/a4281a9d-e8ae-46f2-9d0f-ee2f04109eb6%40googlegroups.com > > <https://groups.google.com/d/msgid/rubyonrails-talk/a4281a9d-e8ae-46f2-9d0f-ee2f04109eb6%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. ---- Jason Fleetwood-Boldt [email protected] http://www.jasonfleetwoodboldt.com/writing All material © Jason Fleetwood-Boldt 2014. Public conversations may be turned into blog posts (original poster information will be made anonymous). Email [email protected] with questions/concerns about this. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4846018C-2620-4A24-8C07-4EE033176CF2%40datatravels.com. For more options, visit https://groups.google.com/d/optout.

