From d727621c463742772ebd37733d0ba43c708e2c78 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 14 Nov 2011 08:35:09 -0500 Subject: [PATCH] Using spork with watchr and all that jazz... though still not feeling like the tests are "blazingly fast" (sigh) --- rails/gerbil/.rspec | 2 +- rails/gerbil/Gemfile | 2 +- rails/gerbil/Gemfile.lock | 2 + rails/gerbil/app/models/person.rb | 1 - rails/gerbil/config/application.rb | 6 ++ rails/gerbil/config/environments/test.rb | 2 +- rails/gerbil/spec/spec_helper.rb | 75 ++++++++++++++---------- 7 files changed, 54 insertions(+), 36 deletions(-) diff --git a/rails/gerbil/.rspec b/rails/gerbil/.rspec index 53607ea..5902dd3 100644 --- a/rails/gerbil/.rspec +++ b/rails/gerbil/.rspec @@ -1 +1 @@ ---colour +--colour --drb diff --git a/rails/gerbil/Gemfile b/rails/gerbil/Gemfile index dda09ad..55ce5d4 100644 --- a/rails/gerbil/Gemfile +++ b/rails/gerbil/Gemfile @@ -36,5 +36,5 @@ group :development, :test do gem 'rspec-rails' gem 'watchr' gem 'rev' - gem 'spork' + gem 'spork', '~> 0.9.0.rc' end diff --git a/rails/gerbil/Gemfile.lock b/rails/gerbil/Gemfile.lock index e8426d4..db1c308 100644 --- a/rails/gerbil/Gemfile.lock +++ b/rails/gerbil/Gemfile.lock @@ -105,6 +105,7 @@ GEM sass (>= 3.1.4) sprockets (~> 2.0.0) tilt (~> 1.3.2) + spork (0.9.0.rc9) sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) @@ -132,6 +133,7 @@ DEPENDENCIES rev rspec-rails sass-rails (~> 3.1.4) + spork (~> 0.9.0.rc) sqlite3 uglifier (>= 1.0.3) watchr diff --git a/rails/gerbil/app/models/person.rb b/rails/gerbil/app/models/person.rb index c2e188d..2f2e286 100644 --- a/rails/gerbil/app/models/person.rb +++ b/rails/gerbil/app/models/person.rb @@ -1,3 +1,2 @@ class Person < ActiveRecord::Base - end diff --git a/rails/gerbil/config/application.rb b/rails/gerbil/config/application.rb index 9ae1bc4..742d7a6 100644 --- a/rails/gerbil/config/application.rb +++ b/rails/gerbil/config/application.rb @@ -50,5 +50,11 @@ module Gerbil # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + + if Rails.env.test? + initializer :after => :initialize_dependency_mechanism do + ActiveSupport::Dependencies.mechanism = :load + end + end end end diff --git a/rails/gerbil/config/environments/test.rb b/rails/gerbil/config/environments/test.rb index 9f1cd43..53de15c 100644 --- a/rails/gerbil/config/environments/test.rb +++ b/rails/gerbil/config/environments/test.rb @@ -5,7 +5,7 @@ Gerbil::Application.configure do # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true + config.cache_classes = false # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true diff --git a/rails/gerbil/spec/spec_helper.rb b/rails/gerbil/spec/spec_helper.rb index 6d7f66d..b8459a7 100644 --- a/rails/gerbil/spec/spec_helper.rb +++ b/rails/gerbil/spec/spec_helper.rb @@ -1,33 +1,44 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../../config/environment", __FILE__) -require 'rspec/rails' -require 'rspec/autorun' - -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} - -RSpec.configure do |config| - # == Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr - config.mock_with :rspec - - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true - - # If true, the base class of anonymous controllers will be inferred - # automatically. This will be the default behavior in future versions of - # rspec-rails. - config.infer_base_class_for_anonymous_controllers = false +require 'spork' + +Spork.prefork do + # This file is copied to spec/ when you run 'rails generate rspec:install' + ENV["RAILS_ENV"] ||= 'test' + require File.expand_path("../../config/environment", __FILE__) + require 'rspec/rails' + require 'rspec/autorun' + + # Requires supporting ruby files with custom matchers and macros, etc, + # in spec/support/ and its subdirectories. + Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + + RSpec.configure do |config| + # == Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + config.mock_with :rspec + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + + ActiveSupport::Dependencies.clear + end +end + +Spork.each_run do + load Rails.root.join("config/routes.rb") + Dir[Rails.root.join("app/**/*.rb")].each { |f| load f } end