diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 2643c2c55..7984efc01 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -23,11 +23,8 @@ jobs: strategy: matrix: - ruby: ["3.1", "3.2", "jruby-9.4", "3.3"] - appraisal: [cucumber_8, cucumber_9] - include: - - ruby: "3.0" - appraisal: cucumber_8 + ruby: ["3.2"] + appraisal: [cucumber_9] env: BUNDLE_GEMFILE: gemfiles/${{ matrix.appraisal }}.gemfile @@ -48,7 +45,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3"] + ruby: ["3.2"] runs-on: macos-latest @@ -68,7 +65,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3"] + ruby: ["3.2"] runs-on: windows-latest @@ -83,6 +80,8 @@ jobs: bundler-cache: true - name: Run specs run: bundle exec rake spec + - name: Run cukes + run: bundle exec rake cucumber checks: diff --git a/fixtures/cli-app/bin/aruba-test-cli.bat b/fixtures/cli-app/bin/aruba-test-cli.bat new file mode 100644 index 000000000..a66c9a78a --- /dev/null +++ b/fixtures/cli-app/bin/aruba-test-cli.bat @@ -0,0 +1,6 @@ +@ECHO OFF +IF NOT "%~f0" == "~f0" GOTO :WinNT +@"ruby.exe" "./aruba-test-cli" %1 %2 %3 %4 %5%6 %7 %8 %9 +GOTO :EOF +:WinNT +@"ruby.exe" "%~dpn0" %* 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 diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb index 2455fe44a..fe3db1dfa 100644 --- a/spec/aruba/api_spec.rb +++ b/spec/aruba/api_spec.rb @@ -40,13 +40,15 @@ end describe "#set_environment_variable" do + let(:get_env_cmd) { FFI::Platform.windows? ? "set" : "env" } + after do @aruba.all_commands.each(&:stop) end it "set environment variable" do @aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "true" - @aruba.run_command_and_stop "env" + @aruba.run_command_and_stop get_env_cmd expect(@aruba.last_command_started.output) .to include("LONG_LONG_ENV_VARIABLE=true") end @@ -54,7 +56,7 @@ it "overwrites environment variable" do @aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "true" @aruba.set_environment_variable "LONG_LONG_ENV_VARIABLE", "false" - @aruba.run_command_and_stop "env" + @aruba.run_command_and_stop get_env_cmd expect(@aruba.last_command_started.output) .to include("LONG_LONG_ENV_VARIABLE=false") end diff --git a/spec/aruba/command_spec.rb b/spec/aruba/command_spec.rb index 8df16af92..62e2e84a6 100644 --- a/spec/aruba/command_spec.rb +++ b/spec/aruba/command_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Aruba::Command do let(:command) do described_class.new( - "true", + "exit 0", event_bus: event_bus, exit_timeout: exit_timeout, io_wait_timeout: io_wait_timeout, diff --git a/spec/aruba/matchers/command_spec.rb b/spec/aruba/matchers/command_spec.rb index dd1fb937f..327fbbc87 100644 --- a/spec/aruba/matchers/command_spec.rb +++ b/spec/aruba/matchers/command_spec.rb @@ -12,7 +12,7 @@ def announcer(*args) end describe "#to_have_exit_status" do - let(:cmd) { "true" } + let(:cmd) { "exit 0" } before { run_command(cmd) } @@ -21,14 +21,14 @@ def announcer(*args) end context "when does not have exit 0" do - let(:cmd) { "false" } + let(:cmd) { "exit 1" } it { expect(last_command_started).not_to have_exit_status 0 } end end describe "#to_be_successfully_executed_" do - let(:cmd) { "true" } + let(:cmd) { "exit 0" } before { run_command(cmd) } @@ -37,7 +37,7 @@ def announcer(*args) end context "when does not have exit 0" do - let(:cmd) { "false" } + let(:cmd) { "exit 1" } it { expect(last_command_started).not_to be_successfully_executed } end