Skip to content

Commit

Permalink
Configure RSpec
Browse files Browse the repository at this point in the history
* 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
Dan Croak committed Oct 23, 2012
1 parent 5270a72 commit 69c7fdd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
12 changes: 8 additions & 4 deletions lib/suspenders/app_builder.rb
Expand Up @@ -100,6 +100,13 @@ def add_capybara_webkit_gem
end

def configure_rspec
remove_file '.rspec'
copy_file 'rspec', '.rspec'
prepend_file 'spec/spec_helper.rb', simplecov_init
replace_in_file 'spec/spec_helper.rb',
'# config.mock_with :mocha',
'config.mock_with :mocha'

generators_config = <<-RUBY
config.generators do |generate|
generate.test_framework :rspec
Expand All @@ -109,6 +116,7 @@ def configure_rspec
generate.view_specs false
end
RUBY

inject_into_class 'config/application.rb', 'Application', generators_config
end

Expand All @@ -133,10 +141,6 @@ def configure_action_mailer

def generate_rspec
generate 'rspec:install'
inject_into_file '.rspec', " --drb", :after => '--color'
prepend_file 'spec/spec_helper.rb', simplecov_init
replace_in_file 'spec/spec_helper.rb',
'# config.mock_with :mocha', 'config.mock_with :mocha'
end

def configure_capybara_webkit
Expand Down
17 changes: 9 additions & 8 deletions lib/suspenders/generators/app_generator.rb
Expand Up @@ -28,13 +28,13 @@ def finish_template

def suspenders_customization
invoke :remove_files_we_dont_need
invoke :customize_gemfile
invoke :setup_development_environment
invoke :setup_test_environment
invoke :setup_staging_environment
invoke :create_suspenders_views
invoke :create_common_javascripts
invoke :add_jquery_ui
invoke :customize_gemfile
invoke :setup_database
invoke :configure_app
invoke :setup_stylesheets
Expand Down Expand Up @@ -62,6 +62,14 @@ def setup_test_environment
say 'Setting up the test environment'
build :enable_factory_girl_syntax
build :test_factories_first
build :generate_rspec
build :configure_rspec

if options[:webkit]
build :configure_capybara_webkit
end

build :setup_guard_spork
end

def setup_staging_environment
Expand Down Expand Up @@ -115,17 +123,10 @@ def setup_database

def configure_app
say 'Configuring app'
build :configure_rspec
build :configure_action_mailer
build :generate_rspec
build :configure_time_zone
build :configure_time_formats

if options[:webkit]
build :configure_capybara_webkit
end

build :setup_guard_spork
build :add_email_validator
build :setup_default_rake_task
build :setup_clearance
Expand Down
3 changes: 3 additions & 0 deletions templates/rspec
@@ -0,0 +1,3 @@
--colour
--drb
--profile

0 comments on commit 69c7fdd

Please sign in to comment.