Sha256: b6c39fc1cb8dd00156abcbdac74f2adb3782ffad4296014663eef15ea00703e9

Contents?: true

Size: 1.65 KB

Versions: 122

Compression:

Stored size: 1.65 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

122 entries across 122 versions & 1 rubygems

Version Path
beaker-4.38.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.38.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.37.2 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.37.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.37.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.36.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.36.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.35.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.34.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.33.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.32.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.31.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.30.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.29.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.29.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.28.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.28.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.27.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.27.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-4.26.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb