From 164530bc88ab9b5e112787c2bc4cbba3beccb59a Mon Sep 17 00:00:00 2001 From: Andrew Walter Date: Fri, 3 Aug 2018 20:15:54 +1000 Subject: [PATCH] CI: Fixed `#run_command` spec on Windows. --- spec/aruba/api/commands_spec.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spec/aruba/api/commands_spec.rb b/spec/aruba/api/commands_spec.rb index 06c9f7776..8b1177cb2 100644 --- a/spec/aruba/api/commands_spec.rb +++ b/spec/aruba/api/commands_spec.rb @@ -6,8 +6,10 @@ include_context "uses aruba API" describe "#run_command" do + let(:cmd) { 'ruby -ne "puts $_"' } + context "when succesfully running a command" do - before { @aruba.run_command "cat" } + before { @aruba.run_command cmd } after { @aruba.all_commands.each(&:stop) } @@ -33,6 +35,15 @@ @aruba.write_file(@file_name, "Hello\nWorld!") @aruba.pipe_in_file(@file_name) @aruba.close_input + + @aruba.last_command_started.stop + last_command_output = @aruba.last_command_started.output + + # Convert \r\n to \n, if present in the output + if last_command_output.include?("\r\n") + allow(@aruba.last_command_started).to receive(:output).and_return(last_command_output.gsub("\r\n", "\n")) + end + expect(@aruba.last_command_started).to have_output "Hello\nWorld!" end end @@ -47,7 +58,7 @@ end it "raises an error" do - expect { @aruba.run_command "cat" }.to raise_error NotImplementedError + expect { @aruba.run_command cmd }.to raise_error NotImplementedError end end