Sha256: be9641ca4f00aa077b986b783474f7a65f0d7374e04019937d3cad67db034977

Contents?: true

Size: 999 Bytes

Versions: 7

Compression:

Stored size: 999 Bytes

Contents

require 'assert'

require 'cap-util/unset_var'

module CapUtil

  class UnsetVarTests < Assert::Context
    desc "the unset var helper"
    setup do
      @var_name = 'test'
      @unset = UnsetVar.new(@var_name)
    end
    subject { @unset }

    should "be a proc" do
      assert_kind_of ::Proc, subject
    end

    should "raise `DeployHalted` when called" do
      assert_raises(CapUtil::DeployHalted) { subject.call }
    end

    should "raise with a default msg based on the variable name" do
      exp_msg = ":#{@var_name} var not set."
      begin
        subject.call
      rescue CapUtil::DeployHalted => err
        assert_match exp_msg, err.message
      end
    end

    should "accept a custom msg to raise with" do
      exp_msg = ":#{@var_name} var not set (a custom err msg)."
      unset = CapUtil::UnsetVar.new(@var_name, exp_msg)
      begin
        unset.call
      rescue CapUtil::DeployHalted => err
        assert_match exp_msg, err.message
      end
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cap-util-0.4.0 test/unset_var_tests.rb
cap-util-0.3.0 test/unset_var_tests.rb
cap-util-0.2.1 test/unset_var_tests.rb
cap-util-0.2.0 test/unset_var_tests.rb
cap-util-0.1.2 test/unset_var_tests.rb
cap-util-0.1.1 test/unset_var_tests.rb
cap-util-0.1.0 test/unset_var_tests.rb