Skip to content

Commit

Permalink
Remove Spork to prepare transition to Spring
Browse files Browse the repository at this point in the history
The application preloader Spring is now integrated in Rails 4.1:
http://stackoverflow.com/questions/23070451/rails-4-1-why-spring
  • Loading branch information
joe4dev committed Mar 24, 2016
1 parent ef0791d commit 4704375
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 114 deletions.
19 changes: 2 additions & 17 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# More info at https://github.com/guard/guard#readme
require 'active_support/inflector'

# Guard docs: https://github.com/guard/guard
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
Expand All @@ -10,24 +10,9 @@ guard 'livereload' do
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg|less))).*}) { |m| "/assets/#{m[3]}" }
end

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' },
:rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('spec/factories.rb') { :rspec }
watch(%r{^spec/factories/.+$}) { :rspec }
watch(%r{^spec/support/(.+)\.rb$}) { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
end

guard :rspec, all_after_pass: false,
all_on_start: true,
cmd: 'rspec --drb --format Fuubar' do
cmd: 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
Expand Down
168 changes: 71 additions & 97 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,109 +1,83 @@
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

# 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.
Spork.prefork do
unless ENV['DRB']
require 'simplecov_rails_custom'
SimpleCov.start 'rails' do
configure_simple_cov
end

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Support for deprecated `its` in RSpec 3 discussed in: https://gist.github.com/myronmarston/4503509
require 'rspec/its'

# Recursively require supporting files (e.g., custom matchers)
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
Dir[Rails.root.join("spec/features/support/**/*.rb")].each { |f| require f }

# Run pending migrations automatically if any
ActiveRecord::Migration.maintain_test_schema!

RSpec.configure do |config|
config.infer_spec_type_from_file_location!

# ## 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"

# 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

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'

config.include FactoryGirl::Syntax::Methods
config.include Capybara::DSL
config.include AuthenticationHelpers, type: :feature

# Must be false for Selenium support
config.use_transactional_fixtures = false

# Authentication helper
config.after(:each) do
Warden.test_reset!
end

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Support for deprecated `its` in RSpec 3 discussed in: https://gist.github.com/myronmarston/4503509
require 'rspec/its'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and spec/features/support and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
Dir[Rails.root.join("spec/features/support/**/*.rb")].each { |f| require f }

# Run pending migrations automatically if any
ActiveRecord::Migration.maintain_test_schema!

RSpec.configure do |config|
config.infer_spec_type_from_file_location!

# ## 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"

# 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

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"

config.include FactoryGirl::Syntax::Methods
config.include Capybara::DSL
config.include AuthenticationHelpers, type: :feature

# Must be false for Selenium support
config.use_transactional_fixtures = false

# Authentication helper
config.after(:each) do
Warden.test_reset!
end
# Database cleaner
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:deletion)
end

# Database cleaner
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end

config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end

config.after(:each) do
# FactoryGirl
config.before(:suite) do
begin
DatabaseCleaner.start
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end

# FactoryGirl
config.before(:suite) do
begin
DatabaseCleaner.start
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end
end

# Clean file system
config.after(:all) do
if Rails.env.test? || Rails.env.cucumber?
FileUtils.rm_rf Dir[Rails.application.config.storage]
end
end
end
end

Spork.each_run do
# This code will be run each time you run your specs.
if ENV['DRB']
require 'simplecov_rails_custom'
SimpleCov.start 'rails' do
configure_simple_cov
# Clean file system
config.after(:all) do
if Rails.env.test? || Rails.env.cucumber?
FileUtils.rm_rf Dir[Rails.application.config.storage]
end
end
end
end

0 comments on commit 4704375

Please sign in to comment.