What exactly does this mean? Am I filling a variable with a hash
Not exactly. When you declare your fixtures, Rails creates one of two
- an instance variable for each fixture in the fixtures file (when
self.use_instantiated_fixtures == true; this yields variables like
- an accessor method named after the entire file (products, in this
case), when self.use_transactional_fixtures == false
In the first case, which is the style used in the book, each
individual fixture, which equates to a row in the database, becomes
an instance variable that you can access using @fixture_name.
In the second case, which is the default style in Rails 1.0, all
fixtures in a file are loaded once and Rails creates a method in your
subclass of Test::Unit::TestCase that allows you to access each of
the fixtures defined in the file by name. So, because you have your
fixtures in a file called ‘products.yml’, Rails creates an accessor
method called products() which takes a single (required) parameter,
which is a symbol identifying the name of the specific fixture you
want – in this case products(:version_control_book).
For best results, you want the two class variables that define the
different behaviors to be mutually exclusive. When
use_transactional_fixtures == true, you want
use_instantiated_fixtures == false, and vice versa. There’s a chance
that a given style will work with both set to true, but it’s not
worth the possible confusion.
And when put in test_helper.rb
./test/functional/…/test_helper.rb:29: undefined method
products' for Test::Unit::TestCase:Class (NoMethodError) from test/functional/store_controller_test.rb:1:inrequire’
This is a signal that Rails wasn’t able (or didn’t try) to create the
accessor method I described above, which I’m guessing means it didn’t
pick up the signal to use the transactional style. Make sure the
transactional one is true and the instantiated one is false, and make
sure you’re using the proper variable style – products
(:fixture_name) – and you should be okay.
Hope this helps,