Sha256: 01d6505520e16d26c5ced7bbb98b17ae4445ce5eef8a4f13a4060b8eadc33cc2

Contents?: true

Size: 1.57 KB

Versions: 40

Compression:

Stored size: 1.57 KB

Contents

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

describe Vagrant::Action::Runner do
  let(:registry) do
    d = double("registry")
    d.stub(:get)
    d
  end

  let(:instance) { described_class.new(registry) }

  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 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(registry, "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(registry) { { "data" => "bar" } }
    instance.run(callable)
    result.should == "bar"
  end
end

Version data entries

40 entries across 40 versions & 6 rubygems

Version Path
bmhatfield-vagrant-1.0.10 test/unit/vagrant/action/runner_test.rb
bmhatfield-vagrant-1.0.9 test/unit/vagrant/action/runner_test.rb
bmhatfield-vagrant-1.0.8 test/unit/vagrant/action/runner_test.rb
bmhatfield-vagrant-1.0.7 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.7 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.6 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.5 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.4 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.3 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.2 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.1 test/unit/vagrant/action/runner_test.rb
vagrantup-1.0.0 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.99.2 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.99.1 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.7 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.6 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.5 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.4 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.3 test/unit/vagrant/action/runner_test.rb
vagrantup-0.9.2 test/unit/vagrant/action/runner_test.rb