Skip to content

Commit

Permalink
Fix some BasicProcess method implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Jan 15, 2022
1 parent 1835b0f commit 2781e97
Showing 1 changed file with 46 additions and 26 deletions.
72 changes: 46 additions & 26 deletions spec/aruba/processes/basic_process_spec.rb
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
require "spec_helper"

RSpec.describe Aruba::Processes::BasicProcess do
let(:process) do
Class.new(described_class) do
def initialize(*args)
@stdout = args.shift
@stderr = args.shift
super(*args)
end

def stdout(*_args)
@stdout
end

def stderr(*_args)
@stderr
end
end.new(stdout, stderr, cmd, exit_timeout, io_wait_timeout, working_directory)
end

let(:cmd) { "foobar" }
let(:exit_timeout) { 0 }
let(:io_wait_timeout) { 0 }
let(:working_directory) { Dir.pwd }
let(:stdout) { "foo output" }
let(:stderr) { "foo error output" }
let(:process) { described_class.new(cmd, exit_timeout, io_wait_timeout, working_directory) }

describe '#inspect' do
let(:stdout) { 'foo output' }
let(:stderr) { 'foo error output' }

let(:derived_process) do
Class.new(described_class) do
def initialize(*args)
@stdout = args.shift
@stderr = args.shift
super(*args)
end

describe "#inspect" do
it "shows useful info" do
def stdout(*_args)
@stdout
end

def stderr(*_args)
@stderr
end
end.new(stdout, stderr, cmd, exit_timeout, io_wait_timeout, working_directory)
end

it 'shows useful info' do
expected = /commandline="foobar": stdout="foo output" stderr="foo error output"/
expect(process.inspect).to match(expected)
expect(derived_process.inspect).to match(expected)
end

context "with no stdout" do
let(:stdout) { nil }

it "shows useful info" do
expected = /commandline="foobar": stdout=nil stderr="foo error output"/
expect(process.inspect).to match(expected)
expect(derived_process.inspect).to match(expected)
end
end

Expand All @@ -46,7 +48,7 @@ def stderr(*_args)

it "shows useful info" do
expected = /commandline="foobar": stdout="foo output" stderr=nil/
expect(process.inspect).to match(expected)
expect(derived_process.inspect).to match(expected)
end
end

Expand All @@ -56,8 +58,26 @@ def stderr(*_args)

it "shows useful info" do
expected = /commandline="foobar": stdout=nil stderr=nil/
expect(process.inspect).to match(expected)
expect(derived_process.inspect).to match(expected)
end
end
end

describe '#stdin' do
it 'raises NotImplementedError' do
expect { process.stdin }.to raise_error NotImplementedError
end
end

describe '#stdout' do
it 'raises NotImplementedError' do
expect { process.stdout }.to raise_error NotImplementedError
end
end

describe '#stderr' do
it 'raises NotImplementedError' do
expect { process.stderr }.to raise_error NotImplementedError
end
end
end

0 comments on commit 2781e97

Please sign in to comment.