Skip to content

Commit

Permalink
Explicely check against timed out command
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed May 31, 2019
1 parent 6e0ef27 commit 34a12af
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions spec/aruba/processes/spawn_process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
subject(:process) { described_class.new(command_line, exit_timeout, io_wait, working_directory) }

let(:command_line) { 'echo "yo"' }
let(:exit_timeout) { 3 }
let(:exit_timeout) { 5 }
let(:io_wait) { 1 }
let(:working_directory) { Dir.getwd }

Expand All @@ -24,20 +24,18 @@
describe '#stderr' do
let(:command_line) { "ruby -e 'warn \"yo\"'" }

before(:each) { process.start }
before(:each) { process.stop }

context 'when invoked once' do
it 'has the right args' do
expect(process.command).to eq 'ruby'
expect(process.arguments).to eq ['-e', 'warn "yo"']
end
before do
process.start
process.stop
end

it { expect(process.stderr.chomp).to eq 'yo' }
it 'returns the output of the process on stderr' do
expect(process).not_to be_timed_out
expect(process.stderr.chomp).to eq 'yo'
end

context 'when invoked twice' do
it { 2.times { expect(process.stderr.chomp).to eq 'yo' } }
it 'returns the same result when invoked a second time' do
2.times { expect(process.stderr.chomp).to eq 'yo' }
end
end

Expand Down Expand Up @@ -181,4 +179,20 @@
end
end
end

describe '#command' do
let(:command_line) { "ruby -e 'warn \"yo\"'" }

it 'returns the first item of the command line' do
expect(process.command).to eq 'ruby'
end
end

describe '#arguments' do
let(:command_line) { "ruby -e 'warn \"yo\"'" }

it 'handles arguments delimited with quotes' do
expect(process.arguments).to eq ['-e', 'warn "yo"']
end
end
end

0 comments on commit 34a12af

Please sign in to comment.