DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Simulating Cookies In RoR Functional Tests

  • submit to reddit
        Okay, my first try didn't work.  This seems to though:
@request.cookies['key'] = 
  'name'   => 'key',
  'value'   => my_value,
  'expires' => 14.days.from_now,
  'path'    => '/',
  'domain'  => ''

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.