2011-11-03 04:59:35 +00:00
|
|
|
require File.expand_path("../base", __FILE__)
|
2011-12-11 23:53:11 +00:00
|
|
|
require "acceptance/support/matchers/have_color"
|
2011-11-03 04:59:35 +00:00
|
|
|
|
2011-11-07 07:47:23 +00:00
|
|
|
describe "vagrant and color output" do
|
|
|
|
include_context "acceptance"
|
|
|
|
|
|
|
|
# This is a check to see if the `expect` program is installed on this
|
|
|
|
# computer. Some tests require this and if this doesn't exist then the
|
|
|
|
# test itself will be skipped.
|
|
|
|
def self.has_expect?
|
2011-11-03 06:16:29 +00:00
|
|
|
`which expect`
|
|
|
|
$?.success?
|
|
|
|
end
|
|
|
|
|
2011-11-07 07:47:23 +00:00
|
|
|
it "outputs color if there is a TTY", :if => has_expect? do
|
|
|
|
environment.workdir.join("color.exp").open("w+") do |f|
|
2011-11-03 06:37:19 +00:00
|
|
|
f.puts(<<-SCRIPT)
|
2011-11-07 07:47:23 +00:00
|
|
|
spawn #{environment.replace_command("vagrant")} status
|
2011-11-03 06:37:19 +00:00
|
|
|
expect default {}
|
2011-11-03 06:16:29 +00:00
|
|
|
SCRIPT
|
|
|
|
end
|
|
|
|
|
2011-11-03 06:37:19 +00:00
|
|
|
result = execute("expect", "color.exp")
|
2011-11-09 07:09:04 +00:00
|
|
|
result.stdout.should have_color
|
2011-11-03 06:16:29 +00:00
|
|
|
end
|
|
|
|
|
2011-11-07 07:47:23 +00:00
|
|
|
it "doesn't output color if there is a TTY but --no-color is present", :if => has_expect? do
|
|
|
|
environment.workdir.join("color.exp").open("w+") do |f|
|
2011-11-03 06:37:19 +00:00
|
|
|
f.puts(<<-SCRIPT)
|
2011-11-07 07:47:23 +00:00
|
|
|
spawn #{environment.replace_command("vagrant")} status --no-color
|
2011-11-03 06:37:19 +00:00
|
|
|
expect default {}
|
2011-11-03 06:16:29 +00:00
|
|
|
SCRIPT
|
|
|
|
end
|
|
|
|
|
2011-11-03 06:37:19 +00:00
|
|
|
result = execute("expect", "color.exp")
|
2011-11-09 07:09:04 +00:00
|
|
|
result.stdout.should_not have_color
|
2011-11-03 06:16:29 +00:00
|
|
|
end
|
|
|
|
|
2011-11-07 07:47:23 +00:00
|
|
|
it "doesn't output color in the absense of a TTY" do
|
2011-11-03 06:16:29 +00:00
|
|
|
# This should always output an error, which on a TTY would
|
2011-11-03 04:59:35 +00:00
|
|
|
# output color. We check that this doesn't output color.
|
|
|
|
# If `vagrant status` itself is broken, another acceptance test
|
|
|
|
# should catch that. We just assume it works here.
|
|
|
|
result = execute("vagrant", "status")
|
2011-11-09 07:09:04 +00:00
|
|
|
result.stdout.should_not have_color
|
2011-11-03 04:59:35 +00:00
|
|
|
end
|
|
|
|
end
|