class SleepingKingStudios::Tasks::Ci::CucumberRunner

Service object to run Cucumber as an external process with the specified parameters.

Public Instance Methods

call(env: {}) click to toggle source
# File lib/sleeping_king_studios/tasks/ci/cucumber_runner.rb, line 13
def call env: {}, files: [], options: [], report: true
  report  = 'tmp/ci/cucumber.json' if report && !report.is_a?(String)
  command =
    build_command(
      :env     => env,
      :files   => files,
      :options => options,
      :report  => report
    ) # end build_command

  stream_process(command)

  report ? load_report(:report => report) : {}
end

Private Instance Methods

base_command() click to toggle source
# File lib/sleeping_king_studios/tasks/ci/cucumber_runner.rb, line 30
def base_command
  'bundle exec cucumber'
end
build_options(files:, options:, report:, **_kwargs) click to toggle source
# File lib/sleeping_king_studios/tasks/ci/cucumber_runner.rb, line 34
def build_options files:, options:, report:, **_kwargs
  options += ['--format=json', "--out=#{report}"] if report

  super :files => files, :options => options
end
load_report(report: raw = File.read report) click to toggle source
# File lib/sleeping_king_studios/tasks/ci/cucumber_runner.rb, line 40
def load_report report:
  raw = File.read report

  return {} if raw.empty?

  json   = JSON.parse raw
  parser = SleepingKingStudios::Tasks::Ci::CucumberParser

  parser.parse(json)
rescue
  {}
end