Created
October 15, 2009 08:48
-
-
Save h-lame/210792 to your computer and use it in GitHub Desktop.
Run all cucumber features and collect failed ones, then run just those failed ones.
This file contains 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
$LOAD_PATH.unshift(Rails.root + '/vendor/plugins/cucumber/lib') if File.directory?(Rails.root + '/vendor/plugins/cucumber/lib') | |
CUCUMBER_FAILED_LOG = Rails.root + "log/cucumber_failed" | |
touch(CUCUMBER_FAILED_LOG) unless File.exist?(CUCUMBER_FAILED_LOG) | |
begin | |
require 'cucumber/rake/task' | |
require "cucumber_rerun_task" | |
namespace :features do | |
Cucumber::Rake::Task.new(:active) do |t| | |
t.cucumber_opts = "-f pretty -f rerun -o #{CUCUMBER_FAILED_LOG} --tags ~@pending --require features" | |
end | |
task :active => 'db:test:prepare' | |
Cucumber::Rake::RerunTask.new(:failed, File.open(CUCUMBER_FAILED_LOG)) do |t| | |
t.cucumber_opts = "-f pretty -f rerun -o #{CUCUMBER_FAILED_LOG} --tags ~@pending --require features" | |
end | |
task :failed => 'db:test:prepare' | |
end | |
desc "Run all features" | |
task :features => ["features:pending", "features:active"] | |
rescue LoadError | |
desc 'Cucumber rake task not available' | |
task :features do | |
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' | |
end | |
end |
This file contains 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
module Cucumber | |
module Rake | |
class DummyRunner | |
def run | |
end | |
end | |
class RerunTask < Task | |
def initialize(task_name, rerun_output, desc = "Run Cucumber features by file and line from the output of -f rerun") | |
@rerun_output = rerun_output | |
super(task_name, desc) | |
end | |
def runner(task_args = nil) | |
if feature_files.any? | |
super | |
else | |
DummyRunner.new | |
end | |
end | |
def feature_files(*ignored) | |
@feature_files ||= if @rerun_output.respond_to?(:read) | |
@rerun_output.read | |
else | |
@rerun_output | |
end.strip.split(/ /) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment