Skip to content

Instantly share code, notes, and snippets.

@tscolari
Last active October 9, 2015 06:18
Show Gist options
  • Save tscolari/3452805 to your computer and use it in GitHub Desktop.
Save tscolari/3452805 to your computer and use it in GitHub Desktop.
Spec for all factories
require 'spec_helper'
describe FactoryGirl do
FactoryGirl.factories.each do |factory|
context "with factory for :#{factory.name}" do
subject {FactoryGirl.build(factory.name)}
it "is valid" do
subject.valid?.should be, subject.errors.full_messages.join(',')
end
context "traits" do
factory.defined_traits.each do |trait|
describe "trait: #{trait.name}" do
subject {FactoryGirl.build(factory.name, trait.name)}
it "is valid" do
subject.valid?.should be, subject.errors.full_messages.join(',')
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment