#!/usr/bin/env ruby require File.dirname(__FILE__) + "/../lib/geordi/setup_firefox_for_selenium" def exec_with_shell_expansion(*args) escaped_args = args.collect do |arg| arg.gsub(/([\\ "])/) { |match| "\\#{$1}" } end exec escaped_args.join(' ') end # Print some whitespace 4.times { puts } puts "Running Cucumber tests..." puts "=========================" # Check if cucumber_spinner is available spinner_available = File.exists?('Gemfile') && File.open('Gemfile').read.scan(/cucumber_spinner/).any? format_args = spinner_available ? ['--format', 'CucumberSpinner::CuriousProgressBarFormatter'] : ['--format', 'progress'] # Check if parallel_tests is available parallel_tests_available = ['rake', 'parallel:spec'] if File.exists?('Gemfile') && File.open('Gemfile').read.scan(/parallel_tests/).any? rerun_txt_exists_and_has_content = File.exists?('rerun.txt') && File.size('rerun.txt') > 0 use_parallel_tests = parallel_tests_available && (ARGV[0] == nil) && !rerun_txt_exists_and_has_content use_firefox_for_selenium = "PATH=#{Geordi::SetupFirefoxForSelenium::FIREFOX_FOR_SELENIUM_PATH}:$PATH" if use_parallel_tests puts "Using parallel_tests ...\n\n" exec_with_shell_expansion *[use_firefox_for_selenium, 'b', 'rake', 'parallel:features', ARGV].flatten else exec_with_shell_expansion *[use_firefox_for_selenium, "b", "cucumber", format_args, ARGV].flatten end