Skip to content

Instantly share code, notes, and snippets.

@npverni
Created August 27, 2009 22:13
Show Gist options
  • Save npverni/176615 to your computer and use it in GitHub Desktop.
Save npverni/176615 to your computer and use it in GitHub Desktop.
should_be_valid_with_factory macro for shoulda/factory_girl
class ActiveSupport::TestCase
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
def self.should_be_valid_with_factory
klass = self.name.gsub(/Test$/, '').downcase.to_sym
should "be valid with factory" do
assert_valid Factory.build(klass)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment