Skip to content

Commit

Permalink
Raise exception if the insert_before middleware is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed May 6, 2012
1 parent 879f98b commit 3d147f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/vagrant/action/builder.rb
Expand Up @@ -57,6 +57,7 @@ def use(middleware, *args, &block)
# 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

Expand Down
7 changes: 6 additions & 1 deletion test/unit/vagrant/action/builder_test.rb
Expand Up @@ -113,7 +113,12 @@ def bar_proc.name; :bar; end
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
Expand Down

0 comments on commit 3d147f1

Please sign in to comment.