module Autotest::CucumberMixin

def make_cucumber_cmd(scenarios_to_run, dirty_scenarios_filename)

def make_cucumber_cmd(scenarios_to_run, dirty_scenarios_filename)
  return '' if scenarios_to_run == []
  
  profiles = YAML.load_file("cucumber.yml").keys rescue []
  
  profile ||= "autotest-all" if profiles.include?("autotest-all") and scenarios_to_run == :all
  profile ||= "autotest"     if profiles.include?("autotest")
  profile ||= nil
  
  if profile
    args = ["--profile", profile]
  else
    args = %w{features --format} << (scenarios_to_run == :all ? "progress" : "pretty")
  end
  args += %w{--format autotest --out} << dirty_scenarios_filename
  args = args.join(' ')
  
  if scenarios_to_run == :all
    scenario_args = nil
  else
    scenario_args = scenarios_to_run.map { |s| "-s '#{s}'" }.join(' ')
  end
  
  return "#{cucumber} #{args} #{scenario_args}"
end