public
Created

  • Download Gist
gistfile1.builder
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# In my test_helper
 
def self.should_have_valid_test_data
klass = self.name[/^(.*)Test$/, 1].constantize
 
test "#{klass.name} should have valid fixtures" do
invalids = klass.all.reject{|m|m.valid?}
message = "Expected all #{klass.name} fixtures to be valid.\nInvalids:\n#{
invalids.map{|m| [m.errors.full_messages, m]}.pretty_inspect}"
assert_block(message) { invalids.empty? }
end
 
test "#{klass.name} should have a valid factory" do
f = Factory.build(klass.name.downcase.to_sym)
f.valid?
message = "Expected #{name} factory to be valid.\nErrors:\n#{f.errors.full_messages.pretty_inspect}"
assert_block(message) { f.valid? }
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.