1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
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" }
describe "#inspect" do
it "shows useful info" do
expected = /commandline="foobar": stdout="foo output" stderr="foo error output"/
expect(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)
end
end
context "with no stderr" do
let(:stderr) { nil }
it "shows useful info" do
expected = /commandline="foobar": stdout="foo output" stderr=nil/
expect(process.inspect).to match(expected)
end
end
context "with neither stderr nor stdout" do
let(:stderr) { nil }
let(:stdout) { nil }
it "shows useful info" do
expected = /commandline="foobar": stdout=nil stderr=nil/
expect(process.inspect).to match(expected)
end
end
end
end
|