Rspec test if a session variable was set in a controller action

rspec, session, testing

Solution

You can access session directly in rspec like this: `session[:key]`. Just compare that with the value you want.

Problem

I have an rspec test that posts to an action. In the action, a session variable is definitely set, however in my controller test, the session hash is empty. How do I check in an Rspec test to see if the controller set the session variable to the right value?

Original source