An easy one: Accessing fixture data in 1.0+


#1

OK, we all know that Rails turned off instantiated fixtures by default
in 1.0. That’s not a problem. However, what I’m now wondering is how
to access the raw fixture data out of the YML file (as opposed to the
database.) Mainly, for comparing my database results with my expected
results in a DRY way.

The book says if you have the command “fixtures :foo”, that you’ll
then have a hash of the YML data in @foo[“name_of_fixture_entry”].
With non-instantiated fixtures, this isn’t there. So where’d it go? I
tried googling for the answer, but it only came back with information
telling me that instantiated fixtures are now turned off.


-Matt T.


#2

Hey,

Matt T. wrote:

OK, we all know that Rails turned off instantiated fixtures by default
in 1.0. That’s not a problem. However, what I’m now wondering is how
to access the raw fixture data out of the YML file (as opposed to the
database.) Mainly, for comparing my database results with my expected
results in a DRY way.

The book says if you have the command “fixtures :foo”, that you’ll
then have a hash of the YML data in @foo[“name_of_fixture_entry”].
With non-instantiated fixtures, this isn’t there. So where’d it go?

It should be in foo[“name_of_fixture_entry”] (without the @).

Michael