Last active
December 18, 2015 03:09
-
-
Save aphexddb/5716347 to your computer and use it in GitHub Desktop.
To make sure that your models are valid you can automatically test all of your factories with the following code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe 'validate FactoryGirl factories' do | |
FactoryGirl.factories.each do |factory| | |
context "with factory for :#{factory.name}" do | |
subject { FactoryGirl.build(factory.name) } | |
it "is valid" do | |
is_valid = subject.valid? | |
is_valid.should be_true, subject.errors.full_messages.join(',') | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment