Is it possible to have several instrument files for each model in rails 3.2?

In Rails 3.2, is it possible to have multiple fixture files for a given ActiveRecord?

The client requires that test data be written to devices, but also require that it be manageable. I would like to break up the instruments a bit, presenting the second set, in which the originals will include / require / display everything.

I could not find anything through Google on how to do this, and the lamps are not my cup of tea. Thanks in advance.

+7
source share
1 answer

It seems to me what you want to do is include the YAML file from another YAML file. This begs the question of how to do this: How to include a YAML file in a YAML file?

Since appliances already have an ERB, it should be as simple as:

<%= IO.read(Rails.root.join "test/other_fixtures/fixture_to_load.yml") %> 

Just make sure that the fixtures are outside the main catalog of devices or the loading mechanism of the fixtures will also try to match them with the model.

If you need ERB inside the device, wrap it in ERB.new , for example:

 <%= ERB.new(IO.read(Rails.root.join "test/other_fixtures/fixture_to_load.yml")).result %> 
+5
source

All Articles