Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Simulating Cookies In RoR Functional Tests

DZone's Guide to

Simulating Cookies In RoR Functional Tests

·
Free Resource
Okay, my first try didn't work.  This seems to though:

@request.cookies['key'] = CGI::Cookie.new( 
  'name'   => 'key',
  'value'   => my_value,
  'expires' => 14.days.from_now,
  'path'    => '/',
  'domain'  => 'example.com'
)


When you're simulating a cookie, you have to go all the way.  It expects it as a CGI::Cookie, set by a hash with strings for keys.
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}