Acceptance tests: Get rid of remaining "assert" statements

This commit is contained in:
Mitchell Hashimoto 2011-11-08 23:09:04 -08:00
parent 4443a323e5
commit 8787c4b876
4 changed files with 15 additions and 12 deletions

View File

@ -78,6 +78,6 @@ describe "vagrant box" do
repackaged_size = repackaged_file.size
logger.debug("Repackaged size: #{repackaged_size}")
size_diff = (repackaged_size - original_size).abs
assert(size_diff < 1000, "Sizes should be very similar")
size_diff.should be < 1000, "Sizes should be very similar"
end
end

View File

@ -5,7 +5,7 @@ describe "vagrant init" do
it "creates a Vagrantfile in the working directory" do
vagrantfile = environment.workdir.join("Vagrantfile")
assert(!vagrantfile.exist?, "Vagrantfile shouldn't exist")
vagrantfile.exist?.should_not be, "Vagrantfile shouldn't exist initially"
result = execute("vagrant", "init")
result.should be_success

View File

@ -0,0 +1,9 @@
RSpec::Matchers.define :have_color do
match do |actual|
actual.index("\e[31m")
end
failure_message_for_should do |actual|
"expected output to contain color, but didn't"
end
end

View File

@ -1,4 +1,5 @@
require File.expand_path("../base", __FILE__)
require "support/matchers/have_color"
describe "vagrant and color output" do
include_context "acceptance"
@ -11,13 +12,6 @@ describe "vagrant and color output" do
$?.success?
end
# This is a helper to check for a color in some text.
# This will return `nil` if no color is found, any other
# truthy value otherwise.
def has_color?(text)
text.index("\e[31m")
end
it "outputs color if there is a TTY", :if => has_expect? do
environment.workdir.join("color.exp").open("w+") do |f|
f.puts(<<-SCRIPT)
@ -27,7 +21,7 @@ SCRIPT
end
result = execute("expect", "color.exp")
assert(has_color?(result.stdout), "output should contain color")
result.stdout.should have_color
end
it "doesn't output color if there is a TTY but --no-color is present", :if => has_expect? do
@ -39,7 +33,7 @@ SCRIPT
end
result = execute("expect", "color.exp")
assert(!has_color?(result.stdout), "output should not contain color")
result.stdout.should_not have_color
end
it "doesn't output color in the absense of a TTY" do
@ -48,6 +42,6 @@ SCRIPT
# If `vagrant status` itself is broken, another acceptance test
# should catch that. We just assume it works here.
result = execute("vagrant", "status")
assert(!has_color?(result.stdout), "output should not contain color")
result.stdout.should_not have_color
end
end