Load All Fixtures (when not in test…)

For tests we have the `fixtures :all`. But for other usages fixture loading is idiotically hard…

Fixtures.create_fixtures(folder, file) should just load all when no file is given, but alas we have to do this ourselves…

#Load all fixtures
Fixtures.reset_cache  #only needed when you reload them
fixtures_folder = File.join(RAILS_ROOT, 'spec', 'fixtures')
fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') }
Fixtures.create_fixtures(fixtures_folder, fixtures)

One thought on “Load All Fixtures (when not in test…)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s