From 2d4e7e59a690b0fe5bbbf4c2923f5a7183a2d7da Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 12 Feb 2014 23:39:54 -0500 Subject: [PATCH] Use spork instead of spring --- .rspec | 2 ++ Gemfile | 4 ++-- Gemfile.lock | 13 +++++++------ Guardfile | 46 ++++++++++++++++++++++++++++++++------------- spec/spec_helper.rb | 24 +++++++++++++++++++++++ 5 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 .rspec diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..08d2ce1 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--drb diff --git a/Gemfile b/Gemfile index a791ef3..35d5272 100644 --- a/Gemfile +++ b/Gemfile @@ -22,10 +22,10 @@ gem 'jbuilder', '~> 1.2' gem 'bootstrap-sass' group :development, :test do - gem 'spring' + gem 'spork' gem 'rspec-rails' - gem 'guard-spring' + gem 'guard-spork' gem 'guard-rspec' end diff --git a/Gemfile.lock b/Gemfile.lock index c3d3e4c..e658bea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,9 +67,10 @@ GEM guard-rspec (4.2.5) guard (~> 2.1) rspec (>= 2.14, < 4.0) - guard-spring (0.0.4) - guard - spring + guard-spork (1.5.0) + childprocess (>= 0.2.3) + guard (>= 1.1) + spork (>= 0.8.4) hike (1.2.3) i18n (0.6.9) jbuilder (1.5.3) @@ -154,7 +155,7 @@ GEM rubyzip (~> 1.0) websocket (~> 1.0.4) slop (3.4.7) - spring (1.1.0) + spork (1.0.0rc4) sprockets (2.10.1) hike (~> 1.2) multi_json (~> 1.0) @@ -193,7 +194,7 @@ DEPENDENCIES coffee-rails (~> 4.0.0) factory_girl_rails guard-rspec - guard-spring + guard-spork jbuilder (~> 1.2) jquery-rails libnotify @@ -202,7 +203,7 @@ DEPENDENCIES sass-rails (~> 4.0.0) sdoc selenium-webdriver - spring + spork sqlite3 terminal-notifier-guard turbolinks diff --git a/Guardfile b/Guardfile index cc0c048..0bc315a 100644 --- a/Guardfile +++ b/Guardfile @@ -1,17 +1,8 @@ # A sample Guardfile # More info at https://github.com/guard/guard#readme +require 'active_support/inflector' -guard 'spring', :rspec_cli => '--color' do - watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^spec/spec_helper\.rb$}) { |m| 'spec' } - watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m| - %W(spec/routing/#{m[1]}_routing_spec.rb spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb spec/requests/#{m[1]}_spec.rb) - end -end - -guard :rspec do +guard 'rspec', all_after_pass: false, cli: '--drb' do if RUBY_PLATFORM.include?('linux') notification :libnotify, :timeout => 5, :transient => true, :append => false, :urgency => :critical @@ -23,20 +14,49 @@ guard :rspec do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } + watch('spec/factories.rb') { "spec" } # Rails example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch('config/routes.rb') { "spec/routing" } + + # Custom Rails Tutorial specs + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m| + ["spec/routing/#{m[1]}_routing_spec.rb", + "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", + "spec/acceptance/#{m[1]}_spec.rb", + (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : + "spec/requests/#{m[1].singularize}_pages_spec.rb")] + end + watch(%r{^app/views/(.+)/}) do |m| + (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : + "spec/requests/#{m[1].singularize}_pages_spec.rb") + end + watch(%r{^app/controllers/sessions_controller\.rb$}) do |m| + "spec/requests/authentication_pages_spec.rb" + end + watch('app/controllers/application_controller.rb') { "spec/controllers" } # Capybara features specs - watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } + watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" } # Turnip features and steps watch(%r{^spec/acceptance/(.+)\.feature$}) watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } end + +guard 'spork', rspec_env: { 'RAILS_ENV' => 'test' }, test_unit: false do + watch('config/application.rb') + watch('config/environment.rb') + watch('config/environments/test.rb') + watch(%r{^config/initializers/.+\.rb$}) + watch('Gemfile') + watch('Gemfile.lock') + watch('spec/spec_helper.rb') { :rspec } + watch('test/test_helper.rb') { :test_unit } +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 86abd90..10d0411 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1 +1,25 @@ require 'rubygems' +require 'spork' + +Spork.prefork do + ENV["RAILS_ENV"] ||= 'test' + require File.expand_path("../../config/environment", __FILE__) + require 'rspec/rails' + require 'rspec/autorun' + + Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } + + ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) + + RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_base_class_for_anonymous_controllers = false + config.order = "random" + config.include Capybara::DSL + end +end + +Spork.each_run do + FactoryGirl.reload +end