Over a million developers have joined DZone.

Load All Fixtures

·
In some test cases I need all my fixtures to be loaded.  To make this easier, add the following to test/test_helper.rb:


class Test::Unit::TestCase
  def self.all_fixtures
    Dir[File.dirname(__FILE__) + "/fixtures/*.yml"].each do |f|
      fixtures File.basename(f, '.yml')
    end
  end

  ..
end


and in your tests use it as follows:


class FooTest < Test::Unit::TestCase
  all_fixtures

  ..
end


Happy testing!
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}