Inside the controller test, you can access session just like you can flash .
here is the helper that I use to set the program id
def set_current_program(program=programs(:direct_debit)) @current_program = program session[:program_id] = @current_program && @current_program.id end
or in setup you can do
def setup session[:var_name] = 1 end
then just run the test as usual
test "should create order" do assert_difference('Order.count') do post :create, :message_text => @order.attributes end end
You can even claim a session value if the action was to change it
assert_equal 24, session[:something_changed]
source share