Sha256: a72e6c99e09e94576d7d1331e2a06751c7fa0f12983bb32e7d1ccc92cb5f95bf

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'open3'

module CLISteps
  def _execute(args = nil)
    Dir.chdir(@__root) do
      Bundler.with_clean_env do
        cmd = ['ruby']
        cmd << '-I' << Gurke.root.join('..', 'lib').realpath
        cmd << '-S' << Gurke.root.join('..', 'bin', 'gurke').realpath

        unless args.to_s.include?('-f ') || args.to_s.include?('--formatter ')
          cmd << '-f' << 'default'
        end

        cmd << args.to_s

        out, err, status = Open3.capture3 cmd.join ' '

        @last_process = [Integer(status), out, err]
      end
    end
  end

  step(/I run the tests with "(.*?)"/, :_execute)

  step('I run the tests', :_execute)

  step(/the program exit code should be null/) do
    expect(@last_process[0]).to eq 0
  end

  step(/the program exit code should be non-null/) do
    expect(@last_process[0]).to_not eq 0
  end

  def _cli_include_content(content)
    expect(@last_process[1] + @last_process[2]).to include content
  end

  step(/the program output should include "(.*?)"/, :_cli_include_content)

  def _cli_not_include_content(content)
    expect(@last_process[1] + @last_process[2]).to_not include content
  end

  step(/the program output should not include "(.*?)"/,
    :_cli_not_include_content)

  step(/all scenarios have passed/) do
    _cli_include_content 'scenarios: 0 failing, 0 pending'
  end
end

Gurke.config.include CLISteps

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gurke-3.3.4 features/support/steps/cli_steps.rb
gurke-3.3.3 features/support/steps/cli_steps.rb
gurke-3.3.2 features/support/steps/cli_steps.rb
gurke-3.3.1 features/support/steps/cli_steps.rb
gurke-3.2.2 features/support/steps/cli_steps.rb
gurke-3.2.1 features/support/steps/cli_steps.rb
gurke-3.2.0 features/support/steps/cli_steps.rb
gurke-3.1.0 features/support/steps/cli_steps.rb
gurke-3.0.0 features/support/steps/cli_steps.rb