Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Configure RSpec

* Use `--profile` flag to display slowest-running specs.
* Re-organize methods so `generate_rspec` only generates RSpec and
  `configure_rspec` only configures RSpec.
  • Loading branch information...
commit 69c7fdd5323d73b5d9eb920e452671a1732a012b 1 parent 5270a72
Dan Croak authored October 19, 2012
12  lib/suspenders/app_builder.rb
@@ -100,6 +100,13 @@ def add_capybara_webkit_gem
100 100
     end
101 101
 
102 102
     def configure_rspec
  103
+      remove_file '.rspec'
  104
+      copy_file 'rspec', '.rspec'
  105
+      prepend_file 'spec/spec_helper.rb', simplecov_init
  106
+      replace_in_file 'spec/spec_helper.rb',
  107
+        '# config.mock_with :mocha',
  108
+        'config.mock_with :mocha'
  109
+
103 110
       generators_config = <<-RUBY
104 111
     config.generators do |generate|
105 112
       generate.test_framework :rspec
@@ -109,6 +116,7 @@ def configure_rspec
109 116
       generate.view_specs false
110 117
     end
111 118
       RUBY
  119
+
112 120
       inject_into_class 'config/application.rb', 'Application', generators_config
113 121
     end
114 122
 
@@ -133,10 +141,6 @@ def configure_action_mailer
133 141
 
134 142
     def generate_rspec
135 143
       generate 'rspec:install'
136  
-      inject_into_file '.rspec', " --drb", :after => '--color'
137  
-      prepend_file 'spec/spec_helper.rb', simplecov_init
138  
-      replace_in_file 'spec/spec_helper.rb',
139  
-        '# config.mock_with :mocha', 'config.mock_with :mocha'
140 144
     end
141 145
 
142 146
     def configure_capybara_webkit
17  lib/suspenders/generators/app_generator.rb
@@ -28,13 +28,13 @@ def finish_template
28 28
 
29 29
     def suspenders_customization
30 30
       invoke :remove_files_we_dont_need
  31
+      invoke :customize_gemfile
31 32
       invoke :setup_development_environment
32 33
       invoke :setup_test_environment
33 34
       invoke :setup_staging_environment
34 35
       invoke :create_suspenders_views
35 36
       invoke :create_common_javascripts
36 37
       invoke :add_jquery_ui
37  
-      invoke :customize_gemfile
38 38
       invoke :setup_database
39 39
       invoke :configure_app
40 40
       invoke :setup_stylesheets
@@ -62,6 +62,14 @@ def setup_test_environment
62 62
       say 'Setting up the test environment'
63 63
       build :enable_factory_girl_syntax
64 64
       build :test_factories_first
  65
+      build :generate_rspec
  66
+      build :configure_rspec
  67
+
  68
+      if options[:webkit]
  69
+        build :configure_capybara_webkit
  70
+      end
  71
+
  72
+      build :setup_guard_spork
65 73
     end
66 74
 
67 75
     def setup_staging_environment
@@ -115,17 +123,10 @@ def setup_database
115 123
 
116 124
     def configure_app
117 125
       say 'Configuring app'
118  
-      build :configure_rspec
119 126
       build :configure_action_mailer
120  
-      build :generate_rspec
121 127
       build :configure_time_zone
122 128
       build :configure_time_formats
123 129
 
124  
-      if options[:webkit]
125  
-        build :configure_capybara_webkit
126  
-      end
127  
-
128  
-      build :setup_guard_spork
129 130
       build :add_email_validator
130 131
       build :setup_default_rake_task
131 132
       build :setup_clearance
3  templates/rspec
... ...
@@ -0,0 +1,3 @@
  1
+--colour
  2
+--drb
  3
+--profile

0 notes on commit 69c7fdd

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