Nubee Fixtures + Tests problem


#1

According to the book, @timesheets[“first_timesheet”] should be
accesible from within my functional test, but its not!

Timesheets.yml :

first_timesheet:
status: 2
start_date: 2006-04-24
cost: 10
employee: 444
id: 10683
charge: 20

My Test :

class AdminTimesheetsControllerTest < Test::Unit::TestCase
fixtures :timesheets

def test_viewTimesheet
get :viewTimesheet,:id=>@timesheets[“first_timesheet”].id
assert_template ‘viewTimesheet’
end
end

The error :

test_viewTimesheet(AdminTimesheetsControllerTest):
NoMethodError: You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]
test/functional/admin_timesheets_controller_test.rb::in
`test_viewTimeshee
t’

any ideas why i cant access it?
Thanks
Andy


#2

What version of rails are you running? I think testing changed in 1.1,
which is biting me right now - try using timesheets(“first_timesheet”)
and
see if it works.

Dan.