Sha256: 89f08d69d711259630092b957ae4cb7c5e8b4df69e6d744f55cffbfad5148097

Contents?: true

Size: 749 Bytes

Versions: 4

Compression:

Stored size: 749 Bytes

Contents

require "test_helper"

class ExceptionCatcherTest < Test::Unit::TestCase
  setup do
    @klass = Class.new
    @klass.send(:include, Vagrant::Action::ExceptionCatcher)
    @env = Vagrant::Action::Environment.new(mock_environment)

    @instance = @klass.new
  end

  should "run block and return result if no exception" do
    result = @instance.catch_action_exception(@env) do
      true
    end

    assert result
    assert !@env.error?
  end

  should "run block and return false with error environment on exception" do
    result = @instance.catch_action_exception(@env) do
      raise Vagrant::Action::ActionException.new(:foo, :foo => :bar)
    end

    assert !result
    assert @env.error?
    assert_equal :foo, @env.error.first
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrantup-0.5.4 test/vagrant/action/exception_catcher_test.rb
vagrantup-0.5.3 test/vagrant/action/exception_catcher_test.rb
vagrant-0.5.4 test/vagrant/action/exception_catcher_test.rb
vagrant-0.5.3 test/vagrant/action/exception_catcher_test.rb