Created
April 11, 2011 13:26
-
-
Save mathie/913507 to your computer and use it in GitHub Desktop.
If you've got to use fixtures, the least you can do is make sure they're actually valid.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class FixturesTest < ActiveSupport::TestCase | |
fixtures(:all).each do |fixture| | |
define_method("test: #{fixture} is valid") do | |
fixture_instances = @loaded_fixtures[fixture] | |
invalid_fixtures = fixture_instances.keys.select do |fixture_name| | |
!fixture_instances[fixture_name].find.valid? | |
end | |
assert_equal 0, invalid_fixtures.length, "Expected #{fixture} fixtures to be valid, but #{invalid_fixtures.to_sentence} #{invalid_fixtures.length == 1 ? "is" : "are"} not." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment