Acceptance test that we can't add boxes with the same name

This commit is contained in:
Mitchell Hashimoto 2012-01-10 18:45:38 -08:00
parent a01d3db40b
commit 7eafb5fc1f
2 changed files with 16 additions and 0 deletions

View File

@ -20,6 +20,18 @@ describe "vagrant box" do
result.stdout.should match_output(:box_installed, "foo")
end
it "errors if attempting to add a box with the same name" do
require_box("default")
# Add the box, which we expect to succeed
assert_execute("vagrant", "box", "add", "foo", box_path("default"))
# Adding it again should not succeed
result = execute("vagrant", "box", "add", "foo", box_path("default"))
result.should_not succeed
result.stderr.should match_output(:box_already_exists, "foo")
end
it "gives an error if the file doesn't exist" do
result = execute("vagrant", "box", "add", "foo", "/tmp/nope/nope/nope/nonono.box")
result.should_not succeed

View File

@ -8,6 +8,10 @@ module Acceptance
@text = text
end
def box_already_exists(name)
@text =~ /^A box already exists under the name of '#{name}'/
end
# Checks that an error message was outputted about the box
# being added being invalid.
def box_invalid