{ "rack.session" => { :username => 'garren'}}
or
:session => {:username => "garren"}
If and one could help me it would be greatly appreciated.
Here is the sample code I've been testing with
Roland
> --
> You received this message because you are subscribed to the Google Groups
> "sinatrarb" group.
> To post to this group, send email to sina...@googlegroups.com.
> To unsubscribe from this group, send email to
> sinatrarb+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sinatrarb?hl=en.
>
Don't know if the info in this thread
http://groups.google.com/group/sinatrarb/browse_thread/thread/4f32eb1165712291
is still relevant to 1.0, but might help.
Roland
On Wed, Mar 31, 2010 at 4:17 PM, Ben Lovell <benjami...@gmail.com> wrote:
> On 31 March 2010 15:23, garren <garren...@gmail.com> wrote:
>>
>> I have searched the net and read every message on this group to try
>> and figure out how to get sessions working with my tests. I cant seem
>> to get it to work. I have tried both methods of:
>>
>> { "rack.session" => { :username => 'garren'}}
>>
>> or
>>
>> :session => {:username => "garren"}
>>
>> If and one could help me it would be greatly appreciated.
>> Here is the sample code I've been testing with
>>
>> http://gist.github.com/350381
>>
>
> I'm seeing the same since upgrading to the 1.0 sinatra, previous version
> doesn't exhibit this behaviour. Pushing a value into the session works when
> you're checking the result in the same route, but doesn't survive redirects
> etc to other routes. I've pushed a quick example up here:
> http://github.com/benlovell/sinatra-sessions
> I think this is a bug.
> Cheers,
> Ben
>
If you really want to do that then you have to use something like
this: http://gist.github.com/295801
Then use like:
get "/", {}, session: {user: 1}
That's because the old behavior was 'wrong' and (as a side effect)
didn't allow for integration tests.
> Pushing a value into the session works when
> you're checking the result in the same route, but doesn't survive redirects
> etc to other routes.
If you want your cookies to survive, you should try Webrat or Capybara
(I recently switched to Capybara because it's much more consistent in
its API, smaller, and provides out-of-the-box Selenium 2.0 support).
On Apr 1, 5:34 pm, Ben Lovell <benjamin.lov...@gmail.com> wrote:
> On 1 April 2010 15:19, Damian Janowski <damian.janow...@gmail.com> wrote:
>
>
>
> > On Wed, Mar 31, 2010 at 12:17 PM, Ben Lovell <benjamin.lov...@gmail.com>
Try Webrat or Capybara.
The default Monk skeleton shows how to set up Webrat and Sinatra
(hurry up before we change it to Capybara).
@Damian, I'll try out Capybara... you seem to be recommending it so
highly.
On Apr 2, 1:04 am, Alex Chaffee <ale...@gmail.com> wrote:
> Rack::Test preserves the rack.session environment variable. So if you define
>
> def session
> last_request.env['rack.session']
> end
>
> in your test/spec helpers then you'll get access to a hash. Set stuff in it
> before calling "get" or "post" and it'll be there for the app under test.
>
> ---
> Alex Chaffee - a...@cohuman.com -http://alexch.github.com
> On Wed, Mar 31, 2010 at 7:23 AM, garren <garren.sm...@gmail.com> wrote:
> > I have searched the net and read every message on this group to try
> > and figure out how to get sessions working with my tests. I cant seem
> > to get it to work. I have tried both methods of:
>
> > { "rack.session" => { :username => 'garren'}}
>
> > or
>
> > :session => {:username => "garren"}
>
> > If and one could help me it would be greatly appreciated.
> > Here is the sample code I've been testing with
>
> >http://gist.github.com/350381
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sinatrarb" group.
> > To post to this group, send email to sina...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > sinatrarb+...@googlegroups.com<sinatrarb%2Bunsu...@googlegroups.com>