Skip to content

Commit

Permalink
Simplify specs for stderr handling
Browse files Browse the repository at this point in the history
Instead of setting up or using a shell script, just use Ruby with a
script on the command line.
  • Loading branch information
mvz committed Feb 2, 2018
1 parent d004b06 commit 0a7d783
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 46 deletions.
3 changes: 0 additions & 3 deletions fixtures/spawn_process/stderr.sh

This file was deleted.

45 changes: 3 additions & 42 deletions spec/aruba/matchers/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,7 @@ def announcer(*args)
end

context 'when have output hello world on stderr' do
before :each do
string = <<-EOS.strip_heredoc
#!/usr/bin/env bash
echo $* >&2
EOS

File.open(expand_path('cmd.sh'), 'w') { |f| f.puts string }

File.chmod 0o755, expand_path('cmd.sh')
prepend_environment_variable 'PATH', "#{expand_path('.')}#{File::PATH_SEPARATOR}"
end

let(:cmd) { "cmd.sh #{output}" }
let(:cmd) { "ruby -e 'warn \"#{output}\"'" }

before(:each) { run_command(cmd) }

Expand All @@ -108,20 +95,7 @@ def announcer(*args)
end

context 'when have output hello world on stderr' do
before :each do
string = <<-EOS.strip_heredoc
#!/usr/bin/env bash
echo $* >&2
EOS

File.open(expand_path('cmd.sh'), 'w') { |f| f.puts string }

File.chmod 0o755, expand_path('cmd.sh')
prepend_environment_variable 'PATH', "#{expand_path('.')}#{File::PATH_SEPARATOR}"
end

let(:cmd) { "cmd.sh #{output}" }
let(:cmd) { "ruby -e 'warn \"#{output}\"'" }

before(:each) { run_command(cmd) }

Expand All @@ -145,20 +119,7 @@ def announcer(*args)
end

context 'when have output hello world on stderr' do
before :each do
string = <<-EOS.strip_heredoc
#!/usr/bin/env bash
echo $* >&2
EOS

File.open(expand_path('cmd.sh'), 'w') { |f| f.puts string }

File.chmod 0o755, expand_path('cmd.sh')
prepend_environment_variable 'PATH', "#{expand_path('.')}#{File::PATH_SEPARATOR}"
end

let(:cmd) { "cmd.sh #{output}" }
let(:cmd) { "ruby -e 'warn \"#{output}\"'" }

before(:each) { run_command(cmd) }

Expand Down
2 changes: 1 addition & 1 deletion spec/aruba/processes/spawn_process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end

describe "#stderr" do
let(:command) { 'fixtures/spawn_process/stderr.sh yo' }
let(:command) { "ruby -e 'warn \"yo\"'" }

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

0 comments on commit 0a7d783

Please sign in to comment.