Raise exception if the insert_before middleware is not found
This commit is contained in:
parent
879f98b5d5
commit
3d147f1d96
|
@ -57,6 +57,7 @@ module Vagrant
|
||||||
# given middleware object.
|
# given middleware object.
|
||||||
def insert(index, middleware, *args, &block)
|
def insert(index, middleware, *args, &block)
|
||||||
index = self.index(index) unless index.is_a?(Integer)
|
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])
|
stack.insert(index, [middleware, args, block])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,12 @@ describe Vagrant::Action::Builder do
|
||||||
data[:data].should == [1, 2, 3]
|
data[:data].should == [1, 2, 3]
|
||||||
end
|
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) }.
|
expect { instance.insert_after "object", appender_proc(1) }.
|
||||||
to raise_error(RuntimeError)
|
to raise_error(RuntimeError)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue