Skip to content

Instantly share code, notes, and snippets.

@ciembor
Created April 30, 2015 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciembor/7795ebe80f857a24193c to your computer and use it in GitHub Desktop.
Save ciembor/7795ebe80f857a24193c to your computer and use it in GitHub Desktop.
namespace :failing_cucumber_specs do
# we have multiple nodes, so we need different file for each node
FAILING_SCENARIOS_FILENAME = "failing_scenarios_#{ENV['CIRCLE_NODE_INDEX']}.txt"
task :record do
# run cucumber and record failing scenarios to the file
begin
Rake::Task['knapsack:cucumber'].invoke("-f rerun --out #{FAILING_SCENARIOS_FILENAME}")
rescue SystemExit => e
# exit 0, we don't want failed build because of this task
puts "#{e.class}: #{e.message}"
exit(0)
end
end
task :rerun do
# we don't need to run cucumber again if all scenarios passed
unless File.zero?("#{FAILING_SCENARIOS_FILENAME}")
# run cucumber with failing scenarios only
cmd = "bundle exec cucumber @#{FAILING_SCENARIOS_FILENAME}"
exec(cmd)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment