Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Create spec/models/factories_spec.rb

  • Loading branch information...
commit 52444ebbb85a1ba426bb8f5c3ee68d1d17d6e63f 1 parent 4c15080
Dan Croak authored October 18, 2012
7  lib/suspenders/app_builder.rb
@@ -23,6 +23,13 @@ def enable_factory_girl_syntax
23 23
       copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
24 24
     end
25 25
 
  26
+    def test_factories_first
  27
+      copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
  28
+      append_file 'Rakefile' do
  29
+        "\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"
  30
+      end
  31
+    end
  32
+
26 33
     def setup_staging_environment
27 34
       run 'cp config/environments/production.rb config/environments/staging.rb'
28 35
       inject_into_file 'config/environments/staging.rb',
6  lib/suspenders/generators/app_generator.rb
@@ -29,6 +29,7 @@ def finish_template
29 29
     def suspenders_customization
30 30
       invoke :remove_files_we_dont_need
31 31
       invoke :setup_development_environment
  32
+      invoke :setup_test_environment
32 33
       invoke :setup_staging_environment
33 34
       invoke :create_suspenders_views
34 35
       invoke :create_common_javascripts
@@ -55,7 +56,12 @@ def remove_files_we_dont_need
55 56
     def setup_development_environment
56 57
       say 'Setting up the development environment'
57 58
       build :raise_delivery_errors
  59
+    end
  60
+
  61
+    def setup_test_environment
  62
+      say 'Setting up the test environment'
58 63
       build :enable_factory_girl_syntax
  64
+      build :test_factories_first
59 65
     end
60 66
 
61 67
     def setup_staging_environment
9  templates/factories_spec.rb
... ...
@@ -0,0 +1,9 @@
  1
+require 'spec_helper'
  2
+
  3
+FactoryGirl.factories.map(&:name).each do |factory_name|
  4
+  describe "the #{factory_name} factory" do
  5
+    it 'is valid' do
  6
+      build(factory_name).should be_valid
  7
+    end
  8
+  end
  9
+end

0 notes on commit 52444eb

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