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-3.10.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.9.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.8.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.7.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.6.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.52.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.5.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.4.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.3.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.2.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.1.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-3.0.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.51.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.50.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.49.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.48.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.48.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.47.1 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.47.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb
beaker-2.46.0 acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb