diff --git a/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb b/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb index bf0962dd5..44e37540c 100644 --- a/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +++ b/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb @@ -5,6 +5,10 @@ require 'securerandom' class ArtifactCli < Minitest::Test include CorePluginFunctionalHelper + before { + skip_windows! + } + def test_generating_archive_keys Dir.mktmpdir do |dir| unique_key_name = SecureRandom.uuid() diff --git a/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb b/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb index 9ec4e50d0..c45e433d9 100644 --- a/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +++ b/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb @@ -5,6 +5,7 @@ class ProfileCli < Minitest::Test include CorePluginFunctionalHelper def setup + skip_windows! @tmpdir = Dir.mktmpdir @habitat_profile = File.join(@tmpdir, 'habitat-profile') run_inspec_process('init profile ' + @habitat_profile) diff --git a/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb b/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb index 441cd8bf4..f551bad85 100644 --- a/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +++ b/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb @@ -3,6 +3,10 @@ require_relative '../../../shared/core_plugin_test_helper.rb' class InitPluginCli < Minitest::Test include CorePluginFunctionalHelper + def setup + skip_windows! + end + def test_generating_inspec_plugin_correct_prefix_required Dir.mktmpdir do |dir| plugin = 'wacky-name' @@ -170,4 +174,4 @@ class InitPluginCli < Minitest::Test -end \ No newline at end of file +end diff --git a/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb b/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb index 9ab0c03b0..226fe655e 100644 --- a/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +++ b/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb @@ -4,6 +4,10 @@ require_relative '../../../shared/core_plugin_test_helper.rb' class InitCli < Minitest::Test include CorePluginFunctionalHelper + def setup + skip_windows! + end + def test_generating_inspec_profile Dir.mktmpdir do |dir| profile = File.join(dir, 'test-profile') @@ -95,4 +99,4 @@ class InitCli < Minitest::Test assert_includes Dir.entries(profile).join, 'README.md' end end -end \ No newline at end of file +end diff --git a/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb b/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb index 7cb92f3c7..2ae90f91d 100644 --- a/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb +++ b/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb @@ -19,6 +19,10 @@ module PluginManagerHelpers end end + def setup + skip_windows! + end + def copy_in_project_config_dir(fixture_name, dest = nil) src = Dir.glob(File.join(project_config_dirs_path, fixture_name, '*')) dest ||= File.join(project_config_dirs_path, 'empty') @@ -49,6 +53,10 @@ end class PluginManagerCliHelp < Minitest::Test include CorePluginFunctionalHelper + def setup + skip_windows! + end + # Main inspec help subcommand listing def test_inspec_help_includes_plugin result = run_inspec_process_with_this_plugin('help') diff --git a/lib/plugins/shared/core_plugin_test_helper.rb b/lib/plugins/shared/core_plugin_test_helper.rb index 89edde0f6..697fe9401 100644 --- a/lib/plugins/shared/core_plugin_test_helper.rb +++ b/lib/plugins/shared/core_plugin_test_helper.rb @@ -16,7 +16,7 @@ require 'inspec/plugin/v2' # Configure Minitest to expose things like `let` class Module - include Minitest::Spec::DSL + include Minitest::Spec::DSL # TODO: NO! remove this! end module Inspec @@ -49,8 +49,11 @@ module CorePluginBaseHelper let(:registry) { Inspec::Plugin::V2::Registry.instance } end +require 'functional/helper' + module CorePluginFunctionalHelper include CorePluginBaseHelper + include FunctionalHelper require 'train' TRAIN_CONNECTION = Train.create('local', command_runner: :generic).connection diff --git a/test/functional/filter_table_test.rb b/test/functional/filter_table_test.rb index fd3bb2043..ed18c6217 100644 --- a/test/functional/filter_table_test.rb +++ b/test/functional/filter_table_test.rb @@ -5,6 +5,10 @@ describe 'filtertable functional tests' do let(:run_opts) { { json: true, ignore_rspec_deprecations: true } } let(:ft_profile_path) { File.join(profile_path, 'filter_table') } + def setup + skip_windows! + end + def run_result_for_controls(controls) cmd = 'exec ' + ft_profile_path + ' --controls ' + controls.join(' ') run_inspec_process(cmd, run_opts) @@ -123,4 +127,4 @@ describe 'filtertable functional tests' do expect_clean_run(controls) end end -end \ No newline at end of file +end diff --git a/test/functional/gitfetcher_test.rb b/test/functional/gitfetcher_test.rb index 9a6002d86..02b3c01f0 100644 --- a/test/functional/gitfetcher_test.rb +++ b/test/functional/gitfetcher_test.rb @@ -6,6 +6,8 @@ require 'yaml' describe 'profiles with git-based dependencies' do include FunctionalHelper before(:all) do + skip_windows! + @tmpdir = Dir.mktmpdir @profile_dir = File.join(@tmpdir, "test-profile") @git_dep_dir = File.join(@tmpdir, "git-dep") diff --git a/test/functional/helper.rb b/test/functional/helper.rb index b968b350e..11e7cfe33 100644 --- a/test/functional/helper.rb +++ b/test/functional/helper.rb @@ -107,6 +107,15 @@ module FunctionalHelper ENV["CHEF_LICENSE"] = "accept-no-persist" end + def skip_windows! + skip_until 2019, 7, 31, "These have never passed" if windows? + end + + def assert_exit_code exp, cmd + exp = 1 if exp != 0 if windows? + assert_equal exp, cmd.exit_status + end + def convert_windows_output(text) text = text.force_encoding("UTF-8") text.gsub!("[PASS]", '✔') @@ -127,7 +136,7 @@ module FunctionalHelper def inspec(commandline, prefix = nil) if is_windows? - invocation = "powershell -NonInteractive -Command \"#{prefix} bundle exec #{exec_inspec} #{commandline}\"" + invocation = "cmd /C \"#{prefix} #{exec_inspec} #{commandline}\"" result = CMD.run_command(invocation) result.stdout.encode!(universal_newline: true) result.stderr.encode!(universal_newline: true) diff --git a/test/functional/inheritance_test.rb b/test/functional/inheritance_test.rb index c36954145..46e554f0c 100644 --- a/test/functional/inheritance_test.rb +++ b/test/functional/inheritance_test.rb @@ -5,6 +5,10 @@ describe 'example inheritance profile' do let(:path) { File.join(examples_path, 'inheritance') } let(:input_file) { File.join(examples_path, 'profile-attribute.yml') } # TODO rename attributes in examples + before { + skip_windows! + } + it 'check succeeds with --profiles-path' do out = inspec('check ' + path + ' --profiles-path ' + examples_path) out.stderr.must_equal '' diff --git a/test/functional/inputs_test.rb b/test/functional/inputs_test.rb index 3563f1ac4..b79c6e9d0 100644 --- a/test/functional/inputs_test.rb +++ b/test/functional/inputs_test.rb @@ -4,6 +4,10 @@ describe 'inputs' do include FunctionalHelper let(:inputs_profiles_path) { File.join(profile_path, 'inputs') } + before { + skip_windows! + } + # This tests being able to load complex structures from # cli option-specified files. [ @@ -18,7 +22,7 @@ describe 'inputs' do cmd += ' --controls ' + input_file result = run_inspec_process(cmd) result.stderr.must_equal '' - result.exit_status.must_equal 0 + assert_exit_code 0, result end end @@ -29,9 +33,11 @@ describe 'inputs' do line = lines.detect { |l| l.include? '--input-file' } line.wont_be_nil end + it 'includes the legacy --attrs option' do result = run_inspec_process('exec help', lock: true) lines = result.stdout.split("\n") +p lines line = lines.detect { |l| l.include? '--attrs' } line.wont_be_nil end @@ -48,13 +54,13 @@ describe 'inputs' do describe 'when the --input-file flag is used' do let(:flag) { '--input-file' } it 'works' do - result.exit_status.must_equal 0 + assert_exit_code 0, result end end describe 'when the --attrs flag is used' do let(:flag) { '--attrs' } it 'works' do - result.exit_status.must_equal 0 + assert_exit_code 0, result end end end @@ -78,7 +84,7 @@ describe 'inputs' do cmd += File.join(inputs_profiles_path, 'metadata-empty') result = run_inspec_process(cmd, json: true) result.stderr.must_include 'WARN: Inputs must be defined as an Array. Skipping current definition.' - result.exit_status.must_equal 0 + assert_exit_code 0, result end it "errors with invalid input types" do @@ -86,7 +92,7 @@ describe 'inputs' do cmd += File.join(inputs_profiles_path, 'metadata-invalid') result = run_inspec_process(cmd, json: true) result.stderr.must_equal "Type 'Color' is not a valid input type.\n" - result.exit_status.must_equal 1 + assert_exit_code 1, result end it "errors with required input not defined" do @@ -94,7 +100,7 @@ describe 'inputs' do cmd += File.join(inputs_profiles_path, 'metadata-required') result = run_inspec_process(cmd, json: true) result.stderr.must_include "Input 'a_required_input' is required and does not have a value.\n" - result.exit_status.must_equal 1 + assert_exit_code 1, result end describe 'when profile inheritance is used' do diff --git a/test/functional/inspec_archive_test.rb b/test/functional/inspec_archive_test.rb index 31cc58d26..9472f6a40 100644 --- a/test/functional/inspec_archive_test.rb +++ b/test/functional/inspec_archive_test.rb @@ -5,6 +5,10 @@ describe 'inspec archive' do include FunctionalHelper let(:auto_dst) { File.expand_path(File.join(repo_path, 'profile-1.0.0.tar.gz')) } + before { + skip_windows! + } + it 'archive is successful' do prepare_examples('profile') do |dir| out = inspec('archive ' + dir + ' --overwrite') diff --git a/test/functional/inspec_artifact_test.rb b/test/functional/inspec_artifact_test.rb index 736f36970..e46c79325 100644 --- a/test/functional/inspec_artifact_test.rb +++ b/test/functional/inspec_artifact_test.rb @@ -5,6 +5,10 @@ require 'securerandom' describe 'inspec exec' do include FunctionalHelper + before { + skip_windows! + } + it 'can generate keys' do prepare_examples do |dir| unique_key_name = SecureRandom.uuid() diff --git a/test/functional/inspec_check_test.rb b/test/functional/inspec_check_test.rb index 556f99205..40b6de3a5 100644 --- a/test/functional/inspec_check_test.rb +++ b/test/functional/inspec_check_test.rb @@ -4,6 +4,10 @@ require 'tmpdir' describe 'inspec check' do include FunctionalHelper + before { + skip_windows! + } + describe 'inspec check with json formatter' do it 'can check a profile and produce valid JSON' do out = inspec('check ' + example_profile + ' --format json') diff --git a/test/functional/inspec_detect_test.rb b/test/functional/inspec_detect_test.rb index 785142f88..9508458b1 100644 --- a/test/functional/inspec_detect_test.rb +++ b/test/functional/inspec_detect_test.rb @@ -3,6 +3,10 @@ require 'functional/helper' describe 'inspec detect' do include FunctionalHelper + before { + skip_windows! + } + it 'outputs the correct data' do res = inspec('detect') res.stderr.must_equal '' diff --git a/test/functional/inspec_exec_automate_test.rb b/test/functional/inspec_exec_automate_test.rb index 43a17cb9c..8b3655724 100644 --- a/test/functional/inspec_exec_automate_test.rb +++ b/test/functional/inspec_exec_automate_test.rb @@ -4,6 +4,10 @@ require 'tempfile' describe 'inspec exec automate' do include FunctionalHelper + before { + skip_windows! + } + let(:config_path) do file = Tempfile.new('config.json') file.write(config_data) diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index cf606a11d..ab6cbf9a1 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -4,6 +4,10 @@ require 'json-schema' describe 'inspec exec with json formatter' do include FunctionalHelper + before { + skip_windows! + } + it 'can execute a simple file and validate the json schema' do out = inspec('exec ' + example_control + ' --reporter json --no-create-lockfile') out.stderr.must_equal '' diff --git a/test/functional/inspec_exec_jsonmin_test.rb b/test/functional/inspec_exec_jsonmin_test.rb index 1f14c3b3d..3fe20a7a3 100644 --- a/test/functional/inspec_exec_jsonmin_test.rb +++ b/test/functional/inspec_exec_jsonmin_test.rb @@ -4,6 +4,10 @@ require 'json-schema' describe 'inspec exec' do include FunctionalHelper + before { + skip_windows! + } + it 'can execute a profile with the mini json formatter and validate its schema' do out = inspec('exec ' + example_profile + ' --reporter json-min --no-create-lockfile') out.stderr.must_equal '' diff --git a/test/functional/inspec_exec_junit_test.rb b/test/functional/inspec_exec_junit_test.rb index ebabf60e5..0b083bedb 100644 --- a/test/functional/inspec_exec_junit_test.rb +++ b/test/functional/inspec_exec_junit_test.rb @@ -4,6 +4,10 @@ require 'rexml/document' describe 'inspec exec with junit formatter' do include FunctionalHelper + before { + skip_windows! + } + it 'can execute a simple file with the junit formatter' do out = inspec('exec ' + example_control + ' --reporter junit --no-create-lockfile') out.stderr.must_equal '' diff --git a/test/functional/inspec_exec_test.rb b/test/functional/inspec_exec_test.rb index df476697b..18caf6b9f 100644 --- a/test/functional/inspec_exec_test.rb +++ b/test/functional/inspec_exec_test.rb @@ -4,6 +4,10 @@ describe 'inspec exec' do include FunctionalHelper let(:looks_like_a_stacktrace) { %r{lib/inspec/.+\.rb:\d+:in} } + before { + skip_windows! + } + it 'can execute the profile' do out = inspec('exec ' + example_profile + ' --no-create-lockfile') out.stderr.must_equal '' @@ -181,9 +185,11 @@ Test Summary: 0 successful, 0 failures, 0 skipped let(:json) { JSON.load(out.stdout) } it 'exits with an error' do - out.stdout.force_encoding(Encoding::UTF_8).must_include "skippy\e[0m\n\e[38;5;247m ↺ This will be skipped super intentionally.\e[0m\n" - out.stdout.force_encoding(Encoding::UTF_8).must_include " ↺ CONTROL database: MySQL Session\e[0m\n\e[38;5;247m ↺ Can't run MySQL SQL checks without authentication\e[0m\n" - out.stdout.force_encoding(Encoding::UTF_8).must_include "Profile Summary: 0 successful controls, 0 control failures, \e[38;5;247m2 controls skipped\e[0m\nTest Summary: 0 successful, 0 failures, \e[38;5;247m2 skipped\e[0m\n" + stdout = out.stdout.force_encoding(Encoding::UTF_8) + + stdout.must_include "skippy\e[0m\n\e[38;5;247m ↺ This will be skipped super intentionally.\e[0m\n" + stdout.must_include " ↺ CONTROL database: MySQL Session\e[0m\n\e[38;5;247m ↺ Can't run MySQL SQL checks without authentication\e[0m\n" + stdout.must_include "Profile Summary: 0 successful controls, 0 control failures, \e[38;5;247m2 controls skipped\e[0m\nTest Summary: 0 successful, 0 failures, \e[38;5;247m2 skipped\e[0m\n" out.exit_status.must_equal 101 end end diff --git a/test/functional/inspec_json_profile_test.rb b/test/functional/inspec_json_profile_test.rb index c55a0a106..a37d76271 100644 --- a/test/functional/inspec_json_profile_test.rb +++ b/test/functional/inspec_json_profile_test.rb @@ -4,6 +4,10 @@ require 'mixlib/shellout' describe 'inspec json' do include FunctionalHelper + before { + skip_windows! + } + it 'read the profile json' do out = inspec('json ' + example_profile) out.stderr.must_equal '' @@ -149,7 +153,8 @@ describe 'inspec json' do it 'can execute a profile with warn calls and parse STDOUT as valid JSON' do out = inspec('json ' + File.join(profile_path, 'warn_logs')) out.exit_status.must_equal 0 - JSON.load(out.stdout) + refute_empty out.stdout + assert_kind_of Hash, JSON.load(out.stdout) end end diff --git a/test/functional/inspec_schema_test.rb b/test/functional/inspec_schema_test.rb index 55a51d01e..155e18941 100644 --- a/test/functional/inspec_schema_test.rb +++ b/test/functional/inspec_schema_test.rb @@ -3,6 +3,10 @@ require 'functional/helper' describe 'inspec schema' do include FunctionalHelper + before { + skip_windows! + } + describe 'extracting the platforms schema export' do it 'can execute a platforms schema command' do out = inspec('schema platforms') diff --git a/test/functional/inspec_shell_test.rb b/test/functional/inspec_shell_test.rb index 74346146e..ac1de4215 100644 --- a/test/functional/inspec_shell_test.rb +++ b/test/functional/inspec_shell_test.rb @@ -3,6 +3,10 @@ require 'functional/helper' describe 'inspec shell tests' do include FunctionalHelper + before { + skip_windows! + } + describe 'cmd' do def do_shell_c(code, exit_status, json = false, stderr = '') json_suffix = " --reporter 'json'" if json diff --git a/test/functional/inspec_supermarket_test.rb b/test/functional/inspec_supermarket_test.rb index 12674d115..bb737d3cf 100644 --- a/test/functional/inspec_supermarket_test.rb +++ b/test/functional/inspec_supermarket_test.rb @@ -3,6 +3,10 @@ require 'functional/helper' describe 'inspec supermarket' do include FunctionalHelper + before { + skip_windows! + } + it 'help' do out = inspec('supermarket help') out.exit_status.must_equal 0 diff --git a/test/functional/inspec_test.rb b/test/functional/inspec_test.rb index 205cd9e94..d1a790d3d 100644 --- a/test/functional/inspec_test.rb +++ b/test/functional/inspec_test.rb @@ -3,6 +3,10 @@ require 'functional/helper' describe 'command tests' do include FunctionalHelper + before { + skip_windows! + } + describe 'version' do it 'provides the version number on stdout' do out = inspec('version') diff --git a/test/functional/inspec_vendor_test.rb b/test/functional/inspec_vendor_test.rb index 6cbd695a8..0d88667fc 100644 --- a/test/functional/inspec_vendor_test.rb +++ b/test/functional/inspec_vendor_test.rb @@ -4,6 +4,10 @@ require 'tmpdir' describe 'example inheritance profile' do include FunctionalHelper + before { + skip_windows! + } + it 'can vendor profile dependencies' do prepare_examples('inheritance') do |dir| out = inspec('vendor ' + dir + ' --overwrite') diff --git a/test/functional/license_test.rb b/test/functional/license_test.rb index 1ef777432..11ffa189b 100644 --- a/test/functional/license_test.rb +++ b/test/functional/license_test.rb @@ -7,6 +7,10 @@ describe 'The license acceptance mechanism' do describe 'when the license has not been accepted' do describe 'when the user passes the --chef-license accept flag' do + before { + skip_windows! + } + it 'should silently work normally' do without_license do Dir.mktmpdir do |tmp_home| @@ -39,6 +43,11 @@ describe 'The license acceptance mechanism' do # Since the license-acceptance library detects TTYs, and changes behavior # if not found, we can't test interactive acceptance anymore describe 'when no mechanism is used to accept the license and we are non-interactive' do + + before { + skip_windows! + } + it 'should exit ASAP with code 172' do without_license do Dir.mktmpdir do |tmp_home| diff --git a/test/functional/logging_test.rb b/test/functional/logging_test.rb index 159ddd652..24085c846 100644 --- a/test/functional/logging_test.rb +++ b/test/functional/logging_test.rb @@ -5,6 +5,10 @@ require 'functional/helper' describe 'Deprecation Facility Behavior' do include FunctionalHelper + before { + skip_windows! + } + let(:profile) { File.join(profile_path, 'deprecation', profile_name) } let(:invocation) { "exec #{profile} #{control_flag}" } # Running in JSON mode has the side-effect of sending log messages to $stderr diff --git a/test/functional/plugins_test.rb b/test/functional/plugins_test.rb index e8a587603..824e817c6 100644 --- a/test/functional/plugins_test.rb +++ b/test/functional/plugins_test.rb @@ -8,6 +8,10 @@ require 'functional/helper' describe 'plugin loader' do include FunctionalHelper + before { + skip_windows! + } + it 'handles an unloadable plugin correctly' do outcome = inspec_with_env('version', INSPEC_CONFIG_DIR: File.join(config_dir_path, 'plugin_error_on_load')) outcome.exit_status.must_equal 2 @@ -30,6 +34,10 @@ end describe 'when disabling plugins' do include FunctionalHelper + before { + skip_windows! + } + describe 'when disabling the core plugins' do it 'should not be able to use core-provided commands' do run_result = run_inspec_process('--disable-core-plugins habitat') @@ -56,6 +64,10 @@ end describe 'cli command plugins' do include FunctionalHelper + before { + skip_windows! + } + it 'is able to respond to a plugin-based cli subcommand' do outcome = inspec_with_env('meaningoflife answer', INSPEC_CONFIG_DIR: File.join(config_dir_path, 'meaning_by_path')) outcome.stderr.wont_include 'Could not find command "meaningoflife"' @@ -94,6 +106,10 @@ end describe 'disable plugin usage message integration' do include FunctionalHelper + before { + skip_windows! + } + it "mentions the --disable-{user,core}-plugins options" do outcome = inspec('help') ['--disable-user-plugins', '--disable-core-plugins'].each do |option| @@ -109,6 +125,10 @@ end describe 'DSL plugin types support' do include PluginFunctionalHelper + before { + skip_windows! + } + let(:fixture_path) { File.join(profile_path, 'dsl_plugins', 'controls', profile_file)} let(:dsl_plugin_path) { File.join(mock_path, 'plugins', 'inspec-dsl-test', 'lib', 'inspec-dsl-test.rb')} let(:run_result) { run_inspec_with_plugin("exec #{fixture_path}", plugin_path: dsl_plugin_path) } @@ -230,6 +250,10 @@ end #=========================================================================================# describe 'train plugin support' do + before { + skip_windows! + } + describe 'when a train plugin is installed' do include FunctionalHelper it 'can run inspec detect against a URL target' do diff --git a/test/functional/ui_test.rb b/test/functional/ui_test.rb index 40bf931f2..4aac85696 100644 --- a/test/functional/ui_test.rb +++ b/test/functional/ui_test.rb @@ -18,6 +18,10 @@ describe 'InSpec UI behavior' do include PluginFunctionalHelper include VisibleSpaces + before { + skip_windows! + } + let(:plugin_path) { File.join(mock_path, 'plugins', 'inspec-test-ui', 'lib', 'inspec-test-ui') } let(:run_result) { run_inspec_with_plugin("#{pre_opts} testui #{feature} #{post_opts}", plugin_path: plugin_path) } let(:pre_opts) { '' } @@ -117,11 +121,10 @@ EOT end describe 'exit codes' do - describe 'normal exit' do let(:feature) { 'exitnormal' } it 'has correct output' do - run_result.exit_status.must_equal 0 + assert_exit_code 0, run_result run_result.stderr.must_equal '' run_result.stdout.must_equal "test exit normal\n" end @@ -130,7 +133,7 @@ EOT describe 'usage exit' do let(:feature) { 'exitusage' } it 'has correct output' do - run_result.exit_status.must_equal 1 + 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" end @@ -139,7 +142,7 @@ EOT describe 'plugin exit' do let(:feature) { 'exitplugin' } it 'has correct output' do - run_result.exit_status.must_equal 2 + assert_exit_code 2, run_result run_result.stderr.must_equal '' run_result.stdout.must_equal "test exit plugin_error\n" end @@ -148,7 +151,7 @@ EOT describe 'skipped exit' do let(:feature) { 'exitskipped' } it 'has correct output' do - run_result.exit_status.must_equal 101 + assert_exit_code 101, run_result run_result.stderr.must_equal '' run_result.stdout.must_equal "test exit skipped_tests\n" end @@ -157,7 +160,7 @@ EOT describe 'failed exit' do let(:feature) { 'exitfailed' } it 'has correct output' do - run_result.exit_status.must_equal 100 + assert_exit_code 100, run_result run_result.stderr.must_equal '' run_result.stdout.must_equal "test exit failed_tests\n" end @@ -171,7 +174,7 @@ EOT describe 'the interactive flag' do let(:feature) { 'interactive' } it "should report the interactive flag is on" do - run_result.exit_status.must_equal 0 + assert_exit_code 0, run_result run_result.stdout.must_include 'true' end end @@ -187,7 +190,7 @@ EOT describe 'prompting' do let(:feature) { 'prompt' } it "should launch apollo" do - run_result.exit_status.must_equal 0 + assert_exit_code 0, run_result run_result.stdout.must_include 'Apollo' end end @@ -200,7 +203,7 @@ EOT describe 'the interactive flag' do let(:feature) { 'interactive' } it "should report the interactive flag is off" do - run_result.exit_status.must_equal 0 + assert_exit_code 0, run_result run_result.stdout.must_include 'false' end end @@ -208,9 +211,9 @@ EOT describe 'prompting' do let(:feature) { 'prompt' } it "should crash with stacktrace" do - run_result.exit_status.must_equal 1 + assert_exit_code 1, run_result run_result.stderr.must_include 'Inspec::UserInteractionRequired' end end end -end \ No newline at end of file +end