[Ruby] bootstrap data in test environment

Geoffrey Grosenbach boss at topfunky.com
Tue Jan 16 10:52:55 PST 2007


On Tue, Jan 16, 2007 at 11:11:13AM -0800, Aaron Patterson wrote:
> I'm working on a rails application with *lots* of bootstrap data (24
> tables).  I'd rather not specify 24 fixtures in my tests, so I was
> wondering if there's a way to get rake to run db:bootstrap:load on the
> test database after creating it?

Another technique that I sometimes use is to load the fixtures in test_helper.rb, or make a class method on Test::Unit::TestCase that you can call from the tests that need it:

class Test::Unit::TestCase
  
  # All test cases will load these
  fixtures :foo, :bar, :baz
  
  # OR...
  
  # Call this method from the tests that need it
  def self.load_my_fixtures
    fixtures :foo, :bar, :baz
  end

end


Geoffrey Grosenbach
boss at topfunky.com
........................
Blog | http://nubyonrails.com
Podcast | http://podcast.rubyonrails.com
Screencast | http://peepcode.com


More information about the Ruby mailing list