Skip to content

Instantly share code, notes, and snippets.

@aphexddb
Last active December 18, 2015 03:09
Show Gist options
  • Save aphexddb/5716347 to your computer and use it in GitHub Desktop.
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
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