Sha256: 700c3f286442bfa6ec030f90c2ca11c0f6739bc07706a3ab1ed671cb6b159bc1

Contents?: true

Size: 1.66 KB

Versions: 8

Compression:

Stored size: 1.66 KB

Contents

require "helpers/test_helper"

test_name "dsl::helpers::host_helpers #shell" do
  step "#shell raises an exception when remote command fails" do
    assert_raises(Beaker::Host::CommandFailure) do
      shell "/bin/nonexistent-command"
    end
  end

  step "#shell makes command output available via `.stdout` on success" do
    output = shell(%Q{echo "echo via on"}).stdout
    assert_equal "echo via on\n", output
  end

  step "#shell makes command error output available via `.stderr` on success" do
    output = shell("/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]).stderr
    assert_match(/No such file/, output)
  end

  step "#shell makes exit status available via `.exit_code`" do
    status = shell(%Q{echo "echo via on"}).exit_code
    assert_equal 0, status
  end

  step "#shell with :acceptable_exit_codes will not fail for named exit codes" do
    result = shell "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]
    output = result.stderr
    assert_match(/No such file/, output)
    status = result.exit_code
    assert_equal 127, status
  end

  step "#shell with :acceptable_exit_codes will fail for other exit codes" do
    assert_raises(Beaker::Host::CommandFailure) do
      shell %Q{echo "echo via on"}, :acceptable_exit_codes => [127]
    end
  end

  step "#shell will pass :environment options to the remote host as ENV settings" do
    result = shell "env", { :environment => { 'FOO' => 'bar' } }
    output = result.stdout

    assert_match(/\bFOO=bar\b/, output)
  end

  step "#shell allows assertions to be used in the optional block" do
    shell %Q{echo "${RANDOM}:${RANDOM}"} do
      assert_match(/\d+:\d+/, stdout)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
beaker-4.42.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.41.2 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.41.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.41.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.40.2 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.40.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.40.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.39.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb