Set up specs to use spork for faster test runs (#157)

This commit is contained in:
did 2011-08-14 12:16:59 -07:00
parent b23f2697e9
commit 408ff098ba
5 changed files with 57 additions and 45 deletions

1
.rspec
View File

@ -1 +1,2 @@
--drb
--colour

View File

@ -72,7 +72,7 @@ group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'spork'
gem 'spork', '~> 0.9.0.rc'
gem 'launchy'
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
end

View File

@ -261,7 +261,7 @@ GEM
ffi (>= 1.0.7)
json_pure
rubyzip
spork (0.8.5)
spork (0.9.0.rc9)
term-ansicolor (1.0.6)
thor (0.14.6)
treetop (1.4.9)
@ -330,7 +330,7 @@ DEPENDENCIES
ruby-debug19
rubyzip
sass (= 3.1.2)
spork
spork (~> 0.9.0.rc)
unicorn
warden
will_paginate

View File

@ -0,0 +1,3 @@
- implement the reverse has_many feature based on the great work of Alex Sanford (#142)
- fix a couple of bugs: #152
- improve the installation procedure about setting carrierwave up (#144)

View File

@ -1,3 +1,9 @@
# Note: if segmentation fault with spork / imagemagick on mac os x, take a look at:
# http://stackoverflow.com/questions/2838307/why-is-this-rmagick-call-generating-a-segmentation-fault
require 'rubygems'
require 'spork'
# figure out where we are being loaded from
if $LOADED_FEATURES.grep(/spec\/spec_helper\.rb/).any?
begin
@ -21,41 +27,32 @@ if $LOADED_FEATURES.grep(/spec\/spec_helper\.rb/).any?
end
end
# 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 'factory_girl'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
FactoryGirl.find_definitions
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# 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 'rspec/rails'
require 'factory_girl'
Locomotive.configure_for_test
FactoryGirl.find_definitions
RSpec.configure do |config|
# 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 }
Locomotive.configure_for_test
RSpec.configure do |config|
config.include(Locomotive::RSpec::Matchers)
# == 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
config.before(:each) do
Locomotive.config.heroku = false
@ -78,4 +75,15 @@ RSpec.configure do |config|
DatabaseCleaner.clean
end
end
end
end
Spork.each_run do
# This code will be run each time you run your specs.
Locomotive.configure_for_test(true)
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# loading ruby file directly breaks the tests
# Dir[Rails.root.join('app/models/*.rb')].each { |f| load f }
end