I have a functional test and am trying to set a session value
…
def test_should_check_number_of_jobs
session[:employee_id] = 1 #@fred.id
post :index
assert_equal 1, assigns(:jobs).size
end
…
when I try to run this test I get the following error
TypeError: Symbol as array index
job_controller_test.rb:29in ‘[]=’
job_controller_test.rb:29in ‘test_should_check_number_of_jobs’
if I hard code the employee_id in the controller and remove the session
call in the test, it works perfectly.
The request/controller/response is meant to be a sufficient stand-in
for the real things, but remember that you’re not running in the
context of the controller where the session method would normally be
found.