How to access session from Rails Integration Test?
问题 Consider the following integration test: test "if there is no user in session, redirect to index and flash message" do open_session do |sess| post '/login', :email => users(:client).email, :password => 'rumpelstiltskin' sess[:user] = nil get '/user_page' assert_redirected_to index_path assert_equal "Your session has expired. Please log in again", flash[:notice] end end This generates error: undefined method '[]=' And, changing to sess.session[:user] = nil generates an error as well: