Get Session in Rails Integration Test
May 18th, 2010
From the results Google gives on this, it seems that about three people in the world are using integration tests in Rails, and two of them stopped programming in 2007.
My goal: to get at session data from within an integration test.
Bad news: I don’t know any way to do this without first calling a controller action from within your integration test.
Good news: I have example code on how to get at it after making a request.
def add_to_cart_integration_test s = open_session s.post url_for(:controller => 'shopping_cart', :action => :add_item, :item_id => 1) s.session.data # a populated session hash s.flash # your flash data end
And there you have it.
