Skip to content

Instantly share code, notes, and snippets.

@rodrigopinto
Created September 13, 2012 23:23
Show Gist options
  • Select an option

  • Save rodrigopinto/3718550 to your computer and use it in GitHub Desktop.

Select an option

Save rodrigopinto/3718550 to your computer and use it in GitHub Desktop.
FactoryGirl.factories.map(&:name).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
build(factory_name).should be_valid
end
end
end
# spec/models/my_model_spec.rb
describe MyModel do
it 'has a valid Factory' do
build(:my_model).should be_valid
end
end
desc 'Run factory specs.'
RSpec::Core::RakeTask.new(:factory_specs) do |t|
t.pattern = './spec/factories_spec.rb'
end
task spec: :factory_specs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment