Raise exception if the insert_before middleware is not found

This commit is contained in:
Mitchell Hashimoto 2012-05-05 22:10:26 -07:00
parent 879f98b5d5
commit 3d147f1d96
2 changed files with 7 additions and 1 deletions

View File

@ -57,6 +57,7 @@ module Vagrant
# given middleware object.
def insert(index, middleware, *args, &block)
index = self.index(index) unless index.is_a?(Integer)
raise "no such middleware to insert before: #{index.inspect}" unless index
stack.insert(index, [middleware, args, block])
end

View File

@ -113,7 +113,12 @@ describe Vagrant::Action::Builder do
data[:data].should == [1, 2, 3]
end
it "raises an exception if an invalid object given" do
it "raises an exception if an invalid object given for insert" do
expect { instance.insert "object", appender_proc(1) }.
to raise_error(RuntimeError)
end
it "raises an exception if an invalid object given for insert_after" do
expect { instance.insert_after "object", appender_proc(1) }.
to raise_error(RuntimeError)
end