diff --git a/test/acceptance/box_test.rb b/test/acceptance/box_test.rb index 803cd47c1..4e9b11a6a 100644 --- a/test/acceptance/box_test.rb +++ b/test/acceptance/box_test.rb @@ -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 diff --git a/test/acceptance/support/output.rb b/test/acceptance/support/output.rb index 44cd28767..a7def8525 100644 --- a/test/acceptance/support/output.rb +++ b/test/acceptance/support/output.rb @@ -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