Peter Hicks <[email protected]> on 2010-01-02 at 16:13:
> Hi Phillip
>
> Phillip Koebbe wrote:
>
>> Have you read about fixtures? It sounds like just what you're looking
>> for.
>
> I'm using fixtures already - they're great. I can't find a way to load a
> specific fixture in to a table. If I could do that, I could load a set of
> data, run the code, check the results, and repeat again for the next test.
My group has mostly moved off fixtures towards factory_girl, but we
still depend on a couple of tables' worth of data to get a basic
environment set up for some of our cucumber features.
For this I use the little-documented method that is used internally by
ActiveRecord::Fixtures called 'create_fixtures'.
> create_fixtures(fixtures_directory, table_names, class_names = {})
http://apidock.com/rails/Fixtures/create_fixtures/class
Since it accepts a directory first, you can store the YAML files
wherever you'd like, and load them when you choose -- in
spec/spec_helper.rb or in individual example groups if you wanted.
Here's a snippet from my features/support/env.rb to give you an idea:
Fixtures.create_fixtures('test/fixtures', 'roles')
Fixtures.create_fixtures('test/fixtures', 'role_members')
Fixtures.create_fixtures('test/fixtures', 'rights')
Hope this helps!
Paul
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users