Ruby on Rails
Thursday, December 4, 2014
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:
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 <muchira@gmail.com> 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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a4281a9d-e8ae-46f2-9d0f-ee2f04109eb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
----
Jason Fleetwood-Boldt
All material © Jason Fleetwood-Boldt 2014. Public conversations may be turned into blog posts (original poster information will be made anonymous). Email jason@datatravels.com with questions/concerns about this.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment