Sha256: d0e9d27d1fcc07340b926f57833b212c4a7959530af500977b5a09d95d9ea7cd
Contents?: true
Size: 1.87 KB
Versions: 141
Compression:
Stored size: 1.87 KB
Contents
# frozen_string_literal: true require 'eac_ruby_base0/runner_with/output' require 'eac_ruby_utils/fs/temp' RSpec.describe ::EacRubyBase0::RunnerWith::Output do let(:runner) do the_module = described_class Class.new do include the_module attr_accessor :temp_dir 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 def default_file_to_output temp_dir.join('default_file') end end end let(:stub_text) { 'STUB_TEXT' } let(:instance) do r = runner.create(argv: runner_argv) r.temp_dir = temp_dir r end let(:temp_dir) { ::EacRubyUtils::Fs::Temp.directory } after { temp_dir.remove } context 'without --output option' do let(:runner_argv) { [stub_text] } it do expect { instance.run }.to output(stub_text).to_stdout_from_any_process end end context 'without --output option as to stdout' do let(:runner_argv) { ['--output', ::EacRubyBase0::RunnerWith::Output::STDOUT_OPTION, stub_text] } it do expect { instance.run }.to output(stub_text).to_stdout_from_any_process end end context 'without --output option as to default file' do let(:output_file) { temp_dir.join('default_file') } let(:runner_argv) do ['--output', ::EacRubyBase0::RunnerWith::Output::DEFAULT_FILE_OPTION, stub_text] end before { instance.run } it { expect(output_file).to exist } it { expect(output_file.read).to eq(stub_text) } end context 'with --output option' do let(:output_file) { temp_dir.join('a output file') } let(:runner_argv) { ['--output', output_file.to_path, stub_text] } before { instance.run } it { expect(output_file).to exist } it { expect(output_file.read).to eq(stub_text) } end end
Version data entries
141 entries across 141 versions & 3 rubygems