Sha256: e1c18cd519d41bb93333b704da8ad0f17541edd6b6e5db1e5eb4630e8398b653

Contents?: true

Size: 1.74 KB

Versions: 19

Compression:

Stored size: 1.74 KB

Contents

require File.expand_path("../../../base", __FILE__)

describe Vagrant::Action::Runner do
  let(:instance) { described_class.new }

  it "should raise an error if an invalid callable is given" do
    expect { instance.run(7) }.to raise_error(ArgumentError, /must be a callable/)
  end

  it "should be able to use a Proc as a callable" do
    callable = Proc.new { raise Exception, "BOOM" }
    expect { instance.run(callable) }.to raise_error(Exception, "BOOM")
  end

  it "should be able to use a Class as a callable" do
    callable = Class.new do
      def initialize(app, env)
      end

      def call(env)
        raise Exception, "BOOM"
      end
    end

    expect { instance.run(callable) }.to raise_error(Exception, "BOOM")
  end

  it "should return the resulting environment" do
    callable = lambda do |env|
      env[:data] = "value"

      # Return nil so we can make sure it isn't using this return value
      nil
    end

    result = instance.run(callable)
    result[:data].should == "value"
  end

  it "should pass options into hash given to callable" do
    result = nil
    callable = lambda do |env|
      result = env["data"]
    end

    instance.run(callable, "data" => "foo")
    result.should == "foo"
  end

  it "should pass global options into the hash" do
    result = nil
    callable = lambda do |env|
      result = env["data"]
    end

    instance = described_class.new("data" => "bar")
    instance.run(callable)
    result.should == "bar"
  end

  it "should yield the block passed to the init method to get lazy loaded globals" do
    result = nil
    callable = lambda do |env|
      result = env["data"]
    end

    instance = described_class.new { { "data" => "bar" } }
    instance.run(callable)
    result.should == "bar"
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/runner_test.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/runner_test.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/runner_test.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/test/unit/vagrant/action/runner_test.rb
tnargav-1.3.6 test/unit/vagrant/action/runner_test.rb
tnargav-1.3.3 test/unit/vagrant/action/runner_test.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/action/runner_test.rb
tnargav-1.2.3 test/unit/vagrant/action/runner_test.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/unit/vagrant/action/runner_test.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/action/runner_test.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/test/unit/vagrant/action/runner_test.rb
tnargav-1.2.2 test/unit/vagrant/action/runner_test.rb
vagrantup-1.1.3 test/unit/vagrant/action/runner_test.rb
vagrantup-1.1.2 test/unit/vagrant/action/runner_test.rb
vagrantup-1.1.1 test/unit/vagrant/action/runner_test.rb
vagrantup-1.1.0 test/unit/vagrant/action/runner_test.rb
vagrantup-1.1.4 test/unit/vagrant/action/runner_test.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/test/unit/vagrant/action/runner_test.rb
vagrant-lxc-0.0.1 vendor/vagrant/test/unit/vagrant/action/runner_test.rb