[rspec-users] Rack::Test + cookies + rspec
Ben Prew
lists at ruby-forum.com
Fri Apr 23 03:15:44 EDT 2010
Ben Lovell wrote:
> On 16 April 2010 15:59, Ben Lovell <benjamin.lovell at gmail.com> wrote:
>
>> Try:
>>
>> post 'whatever', {}, {'rack.session' => {:something=>'value'}}
>>
>> To put things through the session with rack test/sinatra.
>>
>> Sent from my iPhone
>>
>>
> Hmm, hold up, that isn't what you asked for :)
>
> You have to remember that the default Rack::Test::CookieJar#[] only
> returns
> cookies that exactly match the domain and path of the current request so
> be
> sure to check there first.
I think this is more of a Sinatra issue, and not an rspec issue. But,
since I'm a Sinatra fan, I thought I'd weigh in, since I just went
through this and it was harder then I would've expected.
If you want to pass session values in tests, you'll have to disable
sessions in your sinatra app. I've got a blog post at
http://benprew.posterous.com/ with the details.
Also, I had to do this in one of my apps recently, take a look at the
Rakefile, picklespears.com and test/test_player.rb at
http://github.com/benprew/picklespears
--
Posted via http://www.ruby-forum.com/.
More information about the rspec-users
mailing list