Forum: Ruby on Rails Nubee Fixtures + Tests problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ef95a483193716db4913521aa9eed0df?d=identicon&s=25 Andy (Guest)
on 2006-05-03 13:22
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
9e44fa55e7078bff7c3dab8404913928?d=identicon&s=25 Dan Venkitachalam (Guest)
on 2006-05-03 19:07
(Received via mailing list)
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.
This topic is locked and can not be replied to.