Sha256: 5a2afe0734acbea12e069ec3948d8cc2c7972be3e0fdb6b140f15603ef69f3e3

Contents?: true

Size: 1.09 KB

Versions: 30

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'eac_cli/runner_with/output_file'
require 'eac_ruby_utils/fs/temp'

RSpec.describe ::EacCli::RunnerWith::OutputFile do
  let(:runner) do
    the_module = described_class
    Class.new do
      include the_module

      runner_definition do
        desc 'A stub root runner.'
        pos_arg :input_text
      end

      def run
        run_output
      end

      def output_content
        parsed.input_text
      end
    end
  end

  let(:stub_text) { 'STUB_TEXT' }
  let(:instance) { runner.create(argv: runner_argv) }

  context 'without --output-file option' do
    let(:runner_argv) { [stub_text] }

    it do
      expect { instance.run }.to output(stub_text).to_stdout_from_any_process
    end
  end

  context 'with --output-file option' do
    let(:output_file) { ::EacRubyUtils::Fs::Temp.file }
    let(:runner_argv) { ['--output-file', output_file.to_path, stub_text] }

    before do
      instance.run
    end

    after do
      output_file.remove
    end

    it { expect(output_file).to exist }
    it { expect(output_file.read).to eq(stub_text) }
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
avm-tools-0.94.2 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.94.1 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
ehbrs-tools-0.20.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.94.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.93.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.92.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.91.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.90.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.89.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.88.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.87.1 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
ehbrs-tools-0.19.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
ehbrs-tools-0.18.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.87.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
ehbrs-tools-0.17.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.86.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.85.1 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.85.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
ehbrs-tools-0.16.5 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb
avm-tools-0.84.0 vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb