Browse files

[#60] [#62] Add spork and guard

  • Loading branch information...
1 parent 01a58b4 commit 78d6dabb6d5fa5a04cda2fd1e7652f12cee3f79b @croaky croaky committed Aug 3, 2012
View
2 Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- suspenders (1.0.0)
+ suspenders (1.0.1)
bundler (>= 1.1)
rails (= 3.2.6)
View
12 lib/suspenders/app_builder.rb
@@ -86,18 +86,20 @@ def configure_action_mailer
def generate_rspec
generate 'rspec:install'
+ inject_into_file '.rspec', " --drb", :after => '--color'
replace_in_file 'spec/spec_helper.rb',
'# config.mock_with :mocha', 'config.mock_with :mocha'
end
def generate_cucumber
generate 'cucumber:install', '--rspec', '--capybara'
- inject_into_file 'features/support/env.rb',
- %{Capybara.save_and_open_page_path = 'tmp'\n} +
- %{Capybara.javascript_driver = :webkit\n},
- :before => %{Capybara.default_selector = :css}
+ copy_file 'features_support_env.rb', 'features/support/env.rb', :force => true
inject_into_file 'config/cucumber.yml',
- ' -r features', :after => %{default: <%= std_opts %> features}
+ ' -drb -r features', :after => %{default: <%= std_opts %> features}
+ end
+
+ def setup_guard_spork
+ copy_file 'Guardfile', 'Guardfile'
end
def generate_clearance
View
6 lib/suspenders/generators/app_generator.rb
@@ -75,17 +75,21 @@ def add_jquery_ui
def customize_gemfile
build :include_custom_gems
+
if options[:clearance]
build :add_clearance_gem
end
+
bundle_command 'install'
end
def setup_database
say 'Setting up database'
+
if 'postgresql' == options[:database]
build :use_postgres_config_template
end
+
build :create_database
end
@@ -95,6 +99,7 @@ def configure_app
build :configure_action_mailer
build :generate_rspec
build :generate_cucumber
+ build :setup_guard_spork
build :add_email_validator
build :setup_default_rake_task
build :setup_clearance
@@ -104,6 +109,7 @@ def setup_clearance
if options[:clearance]
build :generate_clearance
build :include_clearance_matchers
+
if using_active_record?
build :set_attr_accessibles_on_user
end
View
2 templates/Gemfile_additions
@@ -12,6 +12,8 @@ group :development do
end
group :development, :test do
+ gem 'guard'
+ gem 'guard-spork'
gem 'rspec-rails', '~> 2.9.0'
gem 'sham_rack'
end
View
12 templates/Guardfile
@@ -0,0 +1,12 @@
+guard 'spork' do
+ watch 'config/application.rb'
+ watch 'config/environment.rb'
+ watch %r{^config/environments/.*\.rb$}
+ watch %r{^config/initializers/.*\.rb$}
+ watch 'config/routes.rb'
+ watch 'Gemfile.lock'
+ watch 'spec/factories.rb'
+ watch 'spec/spec_helper.rb'
+ watch %r{^spec/support/.*\.rb$}
+ watch 'config/locales/.*'
+end
View
17 templates/features_support_env.rb
@@ -0,0 +1,17 @@
+require 'spork'
+
+Spork.prefork do
+ ENV['RAILS_ENV'] ||= 'test'
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
+ require 'cucumber/rails'
+
+ Capybara.default_selector = :css
+ Capybara.javascript_driver = :webkit
+ DatabaseCleaner.strategy = :truncation
+end
+
+Spork.each_run do
+ After do
+ DatabaseCleaner.clean
+ end
+end

0 comments on commit 78d6dab

Please sign in to comment.