Skip to content
Browse files

Include factory_girl_rails in development env

Including FactoryGirl in the development environment ensures that
factories get created when default generators are used. Adding
FactoryGirl to development also provides factory functionality when in
the development console.
  • Loading branch information...
1 parent 4fe7b97 commit e9915a89241d5d18d0c7c8e573cbe3cfb9dac243 @geoffharcourt geoffharcourt committed with croaky Mar 8, 2013
Showing with 10 additions and 5 deletions.
  1. +1 −1 templates/Gemfile_clean
  2. +9 −4 templates/factories_spec.rb
View
2 templates/Gemfile_clean
@@ -27,6 +27,7 @@ group :development do
end
group :development, :test do
+ gem 'factory_girl_rails'
gem 'rspec-rails'
gem 'sham_rack'
end
@@ -35,7 +36,6 @@ group :test do
gem 'bourne', require: false
gem 'capybara-webkit', '>= 0.14.1'
gem 'database_cleaner'
- gem 'factory_girl_rails'
gem 'launchy'
gem 'shoulda-matchers'
gem 'simplecov', require: false
View
13 templates/factories_spec.rb
@@ -1,9 +1,14 @@
require 'spec_helper'
-FactoryGirl.factories.map(&:name).each do |factory_name|
- describe "the #{factory_name} factory" do
- it 'is valid' do
- expect(build(factory_name)).to be_valid
+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?
+ expect(is_valid).to be_true, subject.errors.full_messages.join(',')
+ end
end
end
end

0 comments on commit e9915a8

Please sign in to comment.
Something went wrong with that request. Please try again.