Skip to content
Create a gist now

Instantly share code, notes, and snippets.

# In my test_helper
def self.should_have_valid_test_data
klass =[/^(.*)Test$/, 1].constantize
test "#{} should have valid fixtures" do
invalids = klass.all.reject{|m|m.valid?}
message = "Expected all #{} fixtures to be valid.\nInvalids:\n#{{|m| [m.errors.full_messages, m]}.pretty_inspect}"
assert_block(message) { invalids.empty? }
test "#{} should have a valid factory" do
f =
message = "Expected #{name} factory to be valid.\nErrors:\n#{f.errors.full_messages.pretty_inspect}"
assert_block(message) { f.valid? }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.