Loading all Rails test fixtures with fixtures :all
Created at: 27.05.2007 16:39, source: Cody Fauser - Show all , tagged: rails rails testing
Are you as tired as we were of loading 20+ different fixtures in each of your Rails test classes? We were, and we even added a method all_fixtures() to test_helper.rb to do the loading of all our fixtures for us.
Thankfully though, we don't need our own helper method anymore, as the Rails fixtures() method will now accept a symbol :all, which will instruct the test helper to load all of your fixtures automatically.
1 2 3 4 5 6 7 8 |
require File.dirname(__FILE__) + '/../test_helper' class ShopTest < Test::Unit::TestCase fixtures :all # Your tests here end |
As of Rails 1.2.3 this feature has not yet been merged from the trunk. This means that you'll either need to run Edge Rails from Subversion, or install the beta Rails gems as follows:
sudo gem install -s http://gems.rubyonrails.org rails -y
Happy testing!
