diff --git a/Gemfile b/Gemfile index 485ec0fd9f..187bf6db35 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ group :test, :development do gem 'machinist' gem 'capybara' gem 'database_cleaner', '0.7.1', :require => false + gem 'spork', '~> 1.0rc' gem 'pry' end diff --git a/Gemfile.lock b/Gemfile.lock index 83cc1edd3a..4f7541c376 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -235,6 +235,7 @@ GEM actionpack (~> 3.0) activemodel (~> 3.0) slop (2.4.4) + spork (1.0.0rc3) spree (1.1.1) spree_api (= 1.1.1) spree_auth (= 1.1.1) @@ -332,6 +333,7 @@ DEPENDENCIES sass-rails (~> 3.2.3) shoulda-matchers simple_form + spork (~> 1.0rc) spree spree_heroku! spree_i18n! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d8884ab2d2..48f1860969 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,57 +1,68 @@ -# 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' -require 'capybara' -require 'database_cleaner' +require 'rubygems' +require 'spork' +#uncomment the following line to use spork with the debugger +#require 'spork/ext/ruby-debug' -# 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} +Spork.prefork do + ENV["RAILS_ENV"] ||= 'test' + require File.expand_path("../../config/environment", __FILE__) + require 'rspec/rails' + require 'rspec/autorun' + require 'capybara' + require 'database_cleaner' -require 'active_record/fixtures' -fixtures_dir = File.expand_path('../../db/default', __FILE__) -ActiveRecord::Fixtures.create_fixtures(fixtures_dir, ['spree/states', 'spree/countries']) + # 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} + + require 'active_record/fixtures' + fixtures_dir = File.expand_path('../../db/default', __FILE__) + ActiveRecord::Fixtures.create_fixtures(fixtures_dir, ['spree/states', 'spree/countries']) -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 + 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 - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + # 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 = false + # 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 = false - # 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 + # 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 - # ## Filters - # - config.filter_run_excluding :skip => true + # ## Filters + # + config.filter_run_excluding :skip => true - config.before(:suite) do - DatabaseCleaner.strategy = :truncation, { :except => ['spree_countries', 'spree_states'] } + config.before(:suite) do + DatabaseCleaner.strategy = :truncation, { :except => ['spree_countries', 'spree_states'] } + end + + config.before(:each) do + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end + + config.include Spree::UrlHelpers end - - config.before(:each) do - DatabaseCleaner.start - end - - config.after(:each) do - DatabaseCleaner.clean - end - - config.include Spree::UrlHelpers +end + +Spork.each_run do + # Dir["#{File.dirname(__FILE__)}/../app/**/*.rb"].each {|f| load f} + # Rails.application.reload_routes! end