Sha256: b2aba4707a836723f0e79ec42402915b0656d2fb653cb63c913adef6e8836d68

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'deployinator'
require 'deployinator/helpers'
require 'deployinator/helpers/dsh'
require 'test/unit'
require 'mocha/setup'

include Deployinator
include Deployinator::Helpers
include Deployinator::Helpers::DshHelpers

#
# Set of tests for methods in our DshHelpers Module
#
class DshHelperTest < Test::Unit::TestCase

  def test_hosts_for_ignores_comments
    DshHelpers.expects(:`).returns("host1\n#host2\nhost3")
    assert_equal(["host1","host3"], DshHelpers.hosts_for("foo"))
  end

  def test_hosts_for_ignores_comments_whitespace_before
    DshHelpers.expects(:`).returns("host1\n   #host2\nhost3")
    assert_equal(["host1","host3"], DshHelpers.hosts_for("hoo"))
  end

  def test_hosts_for
    DshHelpers.expects(:`).returns("host1\nhost2\nhost3")
    assert_equal(["host1","host2","host3"], DshHelpers.hosts_for("bar"))
  end

  def test_host_for_raises_when_nil
    DshHelpers.expects(:`).returns("")
    # $? is the return value of the previous backtick command
    # we are mocking it
    $?.expects(:exitstatus).returns(1)
    assert_raises(RuntimeError) do
      DshHelpers.hosts_for("baz")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
etsy-deployinator-1.1.1 test/unit/helpers_dsh_test.rb
etsy-deployinator-1.1.0 test/unit/helpers_dsh_test.rb
etsy-deployinator-1.0.2 test/unit/helpers_dsh_test.rb
etsy-deployinator-1.0.1 test/unit/helpers_dsh_test.rb