Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Create spec/models/factories_spec.rb

  • Loading branch information...
commit 52444ebbb85a1ba426bb8f5c3ee68d1d17d6e63f 1 parent 4c15080
@croaky croaky authored
View
7 lib/suspenders/app_builder.rb
@@ -23,6 +23,13 @@ def enable_factory_girl_syntax
copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
end
+ def test_factories_first
+ copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
+ append_file 'Rakefile' do
+ "\ndesc 'Run factory specs.'\nRSpec::Core::RakeTask.new(:factory_specs) do |t|\nt.pattern = './spec/models/factories_spec.rb'\nend\n\ntask spec: :factory_specs\n"
+ end
+ end
+
def setup_staging_environment
run 'cp config/environments/production.rb config/environments/staging.rb'
inject_into_file 'config/environments/staging.rb',
View
6 lib/suspenders/generators/app_generator.rb
@@ -29,6 +29,7 @@ def finish_template
def suspenders_customization
invoke :remove_files_we_dont_need
invoke :setup_development_environment
+ invoke :setup_test_environment
invoke :setup_staging_environment
invoke :create_suspenders_views
invoke :create_common_javascripts
@@ -55,7 +56,12 @@ def remove_files_we_dont_need
def setup_development_environment
say 'Setting up the development environment'
build :raise_delivery_errors
+ end
+
+ def setup_test_environment
+ say 'Setting up the test environment'
build :enable_factory_girl_syntax
+ build :test_factories_first
end
def setup_staging_environment
View
9 templates/factories_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+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
Please sign in to comment.
Something went wrong with that request. Please try again.