rspec and cookies

View: New views
3 Messages — Rating Filter:   Alert me  

rspec and cookies

by David Green :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

can anyone tell me how to test cookies using rspec? specifically, I'd like to be able to set a cookie before a get/post request and also to test the cookies which have been set by a get/post request

I know I can use cookies[:name] = 'value' to set a cookie but how would I set expiry information on such a cookie? when i try to pass a hash {:value => 'value', :expires => 3.days.from_now} the entire hash becomes the value of cookies[:name]

thanks
david

Re: rspec and cookies

by François Beausoleil-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello David,

2007/1/29, David Green <justnothing@...>:
> I know I can use cookies[:name] = 'value' to set a cookie but how would I
> set expiry information on such a cookie? when i try to pass a hash {:value
> => 'value', :expires => 3.days.from_now} the entire hash becomes the value
> of cookies[:name]

When the cookie comes back through the browser, it never has any
expiration or options.  The browser handles that information.  That's
why you can't set those options on the requesting side.

When responding, however... that's another story.

Hope that helps !
--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: rspec and cookies

by David Green :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello David,

2007/1/29, David Green <justnothing@tiscali.co.uk>:
> I know I can use cookies[:name] = 'value' to set a cookie but how would I
> set expiry information on such a cookie? when i try to pass a hash {:value
> => 'value', :expires => 3.days.from_now} the entire hash becomes the value
> of cookies[:name]

When the cookie comes back through the browser, it never has any
expiration or options.  The browser handles that information.  That's
why you can't set those options on the requesting side.

When responding, however... that's another story.

Hope that helps !
--

thanks Francois. That explains a lot.