Skip to content

Instantly share code, notes, and snippets.

@AquisTech
Last active March 23, 2016 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AquisTech/c37fb627f201977319b7 to your computer and use it in GitHub Desktop.
Save AquisTech/c37fb627f201977319b7 to your computer and use it in GitHub Desktop.
Generalized specs to test all factories and traits
require 'rails_helper'
FactoryGirl.factories.each do |factory|
describe "The '#{factory.name}' factory" do
it 'is valid' do
build(factory.name).should be_valid
end
factory.definition.defined_traits.each do |trait|
describe "The '#{trait.name}' trait" do
it 'is valid' do
build(factory.name, trait.name).should be_valid
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment