Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Load All Fixtures

DZone's Guide to

Load All Fixtures

·
Free Resource
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:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}