Created
January 31, 2012 14:04
-
-
Save joshuaclayton/1710644 to your computer and use it in GitHub Desktop.
RSpec + Cucumber + Spork
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--colour --drb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/cucumber.yml | |
<% | |
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | |
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" | |
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --drb --strict --tags ~@wip" | |
%> | |
default: <%= std_opts %> features | |
wip: --tags @wip:3 --wip features | |
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# features/support/env.rb | |
require "rubygems" | |
require "spork" | |
Spork.prefork do | |
require 'cucumber/rails' | |
Capybara.default_selector = :css | |
ActionController::Base.allow_rescue = false | |
begin | |
DatabaseCleaner.strategy = :transaction | |
rescue NameError | |
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." | |
end | |
Cucumber::Rails::Database.javascript_strategy = :truncation | |
end | |
Spork.each_run { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/spec_helper.rb | |
require 'rubygems' | |
require 'spork' | |
Spork.prefork do | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
RSpec.configure do |config| | |
config.use_transactional_fixtures = true | |
config.infer_base_class_for_anonymous_controllers = false | |
config.include FactoryGirl::Syntax::Methods | |
end | |
end | |
Spork.each_run do | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/spork.rake | |
desc "Run spork for rspec and cucumber; press Ctrl+C to stop" | |
task :spork do | |
puts "Running Spork for RSpec and Cucumber" | |
puts "Press Ctrl+C to stop" | |
spork_pids = [Process.spawn("spork rspec"), Process.spawn("spork cucumber")] | |
trap("INT") do | |
spork_pids.each { |pid| Process.kill(9, pid) rescue Errno::ESRCH } | |
puts "Shutting down..." | |
exit 0 | |
end | |
spork_pids.each { |pid| Process.wait(pid) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment