Forum: Ruby on Rails Tests: Can't use items(:fixture_name) in setup method!

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Fc582698581884352e745d1d4c64699d?d=identicon&s=25 Joshua Muheim (josh)
on 2007-04-26 12:31
Hi all

I don't know what happened, but since some time I can't run my tests
anymore because I'm getting the following error:

chraftbuech:~/Webwork/pgbookings josh$ ruby
Loaded suite test/functional/admin/music_labels_controller_test
Finished in 0.156566 seconds.

  1) Error:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
    test/functional/admin/music_labels_controller_test.rb:17:in `setup'

My setup method looks like that:

  def setup
    @controller =
    @request    =
    @response   =

    @bionics_records_id = music_labels(:bionics_records).id

I tracked the error down to the following line (line 17):

@bionics_records_id = music_labels(:bionics_records).id

It seems that music_labels() does not return the corresponding object
anymore! But in my fixtures everything seems ok:

  id: 1
  name: Bionics Records
  origin_country_id: 4
  id: 2
  name: Index Records
  origin_country_id: 1

Can anyone give me a hint what's the problem? When replacing

@bionics_records_id = music_labels(:bionics_records).id


@bionics_records_id = 1

everything works again...

Thanks a lot
A9e5ce6f28587baa2a566eb4f2d76c13?d=identicon&s=25 Jon (Guest)
on 2007-04-26 13:23
(Received via mailing list)
Did you remember to call  "fixtures :music_labels" ?

On Apr 26, 11:31 am, Joshua Muheim <>
Fc582698581884352e745d1d4c64699d?d=identicon&s=25 Joshua Muheim (josh)
on 2007-04-26 13:29
Jon wrote:
> Did you remember to call  "fixtures :music_labels" ?
> On Apr 26, 11:31 am, Joshua Muheim <>

Yes, that's not the problem.
This topic is locked and can not be replied to.