In looking at the new "Agile Web Development with Rails" pdf, we're finding the pdf confusing.

In the old book, fixture data was stored in a var, so you had something like

vc_book=@products["version_control_book"] assert_equal vc_book["id"], @product.id

You knew that the fixture data was loaded into @products, and the db data was contained in @product.id.

This is a fundamental testing methodology called "Golden Reference Model" where the fixture is the golden reference.

In the new scheme, fixtures are referred to as methods, which are seemingly objects. It seems to me the fixture file is lost, we are reading data from the db that has been loaded by the fixture. In the new pdf, comparisions are made to a fixed string. So I have to retype alll my data that is in the fixture? Am I missing something here?

I have a pretty simple request:

I would like a golden reference model. I want to use that reference model (Fixture) to compare output from the model, controllers, etc. Do I have to read the fixture file into the test method to compare? If so, how come there isn't a YAML import example in the book?

The new pdf's method of comparing vs. fixed strings is unacceptable.

We have three people, and everyone is generally confused. Maybe we're just dumb... but we've posted this several times in more complicated forms, and it doesn't seem to be addressed. Hopefully this post is simple enough where it can get us going in a direction.


Can you give an example where you are stuck? I don’t know where the problem is.

Fixtures are supposed to be referenced as such:

assert_equals ‘expected’, fixture_type(:fixture_name).attribute


Hi Jason,

When I use the string 'expected' it's hard coded into the test. I don't want to do that. Typically I want to iterate of a set of values. So what we do is something like (using an xml example)

xml.elements.each(somePath){|lelement|   assert_equals element.text localFixture[:fixture_name].attribute }

where localFixture is the fixture file read via YAML. If I use your fixture_type, it seems to me that the item data is from the database - not the fixture file - which violates our golden model rule. It seems like the fixture file is loaded into the db, and then all calls to fixture_type is actually going through the db rather than the fixture file.

Appreciate the help.