I have general application behavior that changes based on cookie contents, and need to test it. As an example, if a user doesn't have a cookie set indicating that they've accepted the site's legal terms, they need to be redirected to the T&C page.
I can set a cookie in a functional test using
request.cookies["legal_accepted"] = "yes"
However, this will not work in an integration test- there's no request object to work with. I've been unable to find any documentation of why this is so, what else is different, and best practices for working with the difference. How can I set a cookie for a given request? Is the why and wherefore documented anywhere?
For Rails 5 integration tests metkat's answer should be altered slightly:
get "/", headers: {"HTTP_COOKIE" => "legal_accepted=yes; cookie2=value2;"}