# Has to be the first file required so that all other files show coverage information
require 'simplecov'

#
# Standard Library
#

require 'pathname'

#
# Gems
#

require 'aruba/cucumber'
# only does jruby customization if actually in JRuby
require 'aruba/jruby'

Before do |scenario|
  command_name = scenario.name

  # Support scenario outlines (scenarios that have "example" tables)
  if scenario.respond_to?(:scenario_outline)
    command_name = "#{scenario.scenario_outline.name} #{command_name}"
  end

  # Used in simplecov_setup so that each scenario has a different name and their coverage results are merged instead
  # of overwriting each other as 'Cucumber Features'
  set_env('SIMPLECOV_COMMAND_NAME', command_name)

  simplecov_setup_pathname = Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')
  # set environment variable so child processes will merge their coverage data with parent process's coverage data.
  set_env('RUBYOPT', "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}")
end

Before do
  @aruba_timeout_seconds = 10 * 60
end

# Has to be the first file required so that all other files show coverage information
require 'simplecov'

#
# Standard Library
#

require 'pathname'

#
# Gems
#

require 'aruba/cucumber'
# only does jruby customization if actually in JRuby
require 'aruba/jruby'

Before do |scenario|
  command_name = case scenario
                   when Cucumber::Ast::Scenario, Cucumber::Ast::ScenarioOutline
                     "#{scenario.feature.title} #{scenario.name}"
                   when Cucumber::Ast::OutlineTable::ExampleRow
                     scenario_outline = scenario.scenario_outline

                     "#{scenario_outline.feature.title} #{scenario_outline.name} #{scenario.name}"
                   else
                     raise TypeError, "Don't know how to extract command name from #{scenario.class}"
                 end

  # Used in simplecov_setup so that each scenario has a different name and their coverage results are merged instead
  # of overwriting each other as 'Cucumber Features'
  set_env('SIMPLECOV_COMMAND_NAME', command_name)

  simplecov_setup_pathname = Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')
  # set environment variable so child processes will merge their coverage data with parent process's coverage data.
  set_env('RUBYOPT', "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}")
end

Before do
  @aruba_timeout_seconds = 10 * 60
end

Include feature title in simplecov command name
Include feature title in simplecov command name

MSP-9923

False negative coverage due to command name collisions when using just
the scenario and scenario outline name because I wasn't including the
feature name.
