mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Revamped test/functional/ui_test.rb to check output before exit codes.
Helps with debugging. Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
parent
fae4230a41
commit
dd7f9abb20
1 changed files with 17 additions and 15 deletions
|
@ -32,19 +32,18 @@ describe "InSpec UI behavior" do
|
|||
describe "headline" do
|
||||
let(:feature) { "headline" }
|
||||
it "has correct output" do
|
||||
run_result.exit_status.must_equal 0
|
||||
expected = <<-EOT
|
||||
|
||||
───────────────────────────────── \e[1m\e[37mBig News!\e[0m ───────────────────────────────── \n
|
||||
EOT
|
||||
show_spaces(run_result.stdout).must_equal show_spaces(expected)
|
||||
run_result.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "table" do
|
||||
let(:feature) { "table" }
|
||||
it "has correct output" do
|
||||
run_result.exit_status.must_equal 0
|
||||
expected = <<~EOT
|
||||
┌──────────────────────┬──────────┬───────────┐
|
||||
│\e[1m\e[37m Band \e[0m│\e[1m\e[37m Coolness \e[0m│\e[1m\e[37m Nerd Cred \e[0m│
|
||||
|
@ -55,39 +54,40 @@ describe "InSpec UI behavior" do
|
|||
└──────────────────────┴──────────┴───────────┘
|
||||
EOT
|
||||
show_spaces(run_result.stdout).must_equal show_spaces(expected)
|
||||
run_result.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "warning" do
|
||||
let(:feature) { "warning" }
|
||||
it "has correct output" do
|
||||
run_result.exit_status.must_equal 0
|
||||
expected = <<~EOT
|
||||
\e[1m\e[33mWARNING:\e[0m Things will be OK in the end
|
||||
EOT
|
||||
show_spaces(run_result.stdout).must_equal show_spaces(expected)
|
||||
run_result.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "error" do
|
||||
let(:feature) { "error" }
|
||||
it "has correct output" do
|
||||
run_result.exit_status.must_equal 0
|
||||
expected = <<~EOT
|
||||
\e[1m\e[38;5;9mERROR:\e[0m Burned down, fell over, and then sank into the swamp.
|
||||
EOT
|
||||
show_spaces(run_result.stdout).must_equal show_spaces(expected)
|
||||
run_result.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "list_item" do
|
||||
let(:feature) { "list_item" }
|
||||
it "has correct output" do
|
||||
run_result.exit_status.must_equal 0
|
||||
expected = <<-EOT
|
||||
\e[1m\e[37m•\e[0m TODO: make more lists
|
||||
EOT
|
||||
show_spaces(run_result.stdout).must_equal show_spaces(expected)
|
||||
run_result.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -97,8 +97,9 @@ describe "InSpec UI behavior" do
|
|||
let(:post_opts) { "--no-color" }
|
||||
describe "everything" do
|
||||
let(:feature) { "everything" }
|
||||
|
||||
it "has correct output" do
|
||||
run_result.exit_status.must_equal 0
|
||||
# TODO: trailing whitespace required in tests. Hidden via "--- \n"
|
||||
expected = <<~EOT
|
||||
|
||||
--------------------------------- Big News! --------------------------------- \n
|
||||
|
@ -114,6 +115,7 @@ describe "InSpec UI behavior" do
|
|||
* TODO: make more lists
|
||||
EOT
|
||||
show_spaces(run_result.stdout).must_equal show_spaces(expected)
|
||||
run_result.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -122,45 +124,45 @@ describe "InSpec UI behavior" do
|
|||
describe "normal exit" do
|
||||
let(:feature) { "exitnormal" }
|
||||
it "has correct output" do
|
||||
assert_exit_code 0, run_result
|
||||
run_result.stderr.must_equal ""
|
||||
run_result.stdout.must_equal "test exit normal\n"
|
||||
assert_exit_code 0, run_result
|
||||
end
|
||||
end
|
||||
|
||||
describe "usage exit" do
|
||||
let(:feature) { "exitusage" }
|
||||
it "has correct output" do
|
||||
assert_exit_code 1, run_result
|
||||
run_result.stderr.must_equal "" # ie, we intentionally exit-1'd; not a crash
|
||||
run_result.stdout.must_equal "test exit usage_error\n"
|
||||
assert_exit_code 1, run_result
|
||||
end
|
||||
end
|
||||
|
||||
describe "plugin exit" do
|
||||
let(:feature) { "exitplugin" }
|
||||
it "has correct output" do
|
||||
assert_exit_code 2, run_result
|
||||
run_result.stderr.must_equal ""
|
||||
run_result.stdout.must_equal "test exit plugin_error\n"
|
||||
assert_exit_code 2, run_result
|
||||
end
|
||||
end
|
||||
|
||||
describe "skipped exit" do
|
||||
let(:feature) { "exitskipped" }
|
||||
it "has correct output" do
|
||||
assert_exit_code 101, run_result
|
||||
run_result.stderr.must_equal ""
|
||||
run_result.stdout.must_equal "test exit skipped_tests\n"
|
||||
assert_exit_code 101, run_result
|
||||
end
|
||||
end
|
||||
|
||||
describe "failed exit" do
|
||||
let(:feature) { "exitfailed" }
|
||||
it "has correct output" do
|
||||
assert_exit_code 100, run_result
|
||||
run_result.stderr.must_equal ""
|
||||
run_result.stdout.must_equal "test exit failed_tests\n"
|
||||
assert_exit_code 100, run_result
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -172,8 +174,8 @@ describe "InSpec UI behavior" do
|
|||
describe "the interactive flag" do
|
||||
let(:feature) { "interactive" }
|
||||
it "should report the interactive flag is on" do
|
||||
assert_exit_code 0, run_result
|
||||
run_result.stdout.must_include "true"
|
||||
assert_exit_code 0, run_result
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -188,8 +190,8 @@ describe "InSpec UI behavior" do
|
|||
describe "prompting" do
|
||||
let(:feature) { "prompt" }
|
||||
it "should launch apollo" do
|
||||
assert_exit_code 0, run_result
|
||||
run_result.stdout.must_include "Apollo"
|
||||
assert_exit_code 0, run_result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -201,16 +203,16 @@ describe "InSpec UI behavior" do
|
|||
describe "the interactive flag" do
|
||||
let(:feature) { "interactive" }
|
||||
it "should report the interactive flag is off" do
|
||||
assert_exit_code 0, run_result
|
||||
run_result.stdout.must_include "false"
|
||||
assert_exit_code 0, run_result
|
||||
end
|
||||
end
|
||||
|
||||
describe "prompting" do
|
||||
let(:feature) { "prompt" }
|
||||
it "should crash with stacktrace" do
|
||||
assert_exit_code 1, run_result
|
||||
run_result.stderr.must_include "Inspec::UserInteractionRequired"
|
||||
assert_exit_code 1, run_result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue