mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
fix and add test
This commit is contained in:
parent
a779d1813d
commit
5d5aa6354d
4 changed files with 22 additions and 2 deletions
|
@ -367,7 +367,7 @@ class InspecRspecCli < InspecRspecJson # rubocop:disable Metrics/ClassLength
|
|||
control_result.each do |test|
|
||||
control_id = ''
|
||||
test_result = test[:code_desc].split[2..-1].join(' ')
|
||||
test_result = test[:message] unless test[:message].nil?
|
||||
test_result = test[:message] unless test[:exception].nil?
|
||||
status_indicator = test[:status_type]
|
||||
print_line(
|
||||
color: @colors[status_indicator] || '',
|
||||
|
|
|
@ -22,6 +22,7 @@ module FunctionalHelper
|
|||
let(:example_profile) { File.join(examples_path, 'profile') }
|
||||
let(:example_control) { File.join(example_profile, 'controls', 'example.rb') }
|
||||
let(:inheritance_profile) { File.join(examples_path, 'profile') }
|
||||
let(:failure_control) { File.join(profile_path, 'failures', 'controls', 'failures.rb') }
|
||||
|
||||
let(:dst) {
|
||||
# create a temporary path, but we only want an auto-clean helper
|
||||
|
|
|
@ -130,7 +130,7 @@ Summary: \e[32m1 successful\e[0m, \e[31m1 failures\e[0m, \e[37m1 skipped\e[0m
|
|||
Target: local://
|
||||
|
||||
\e[32m \xE2\x9C\x94 tmp-1.0: Create /tmp directory\e[0m
|
||||
\e[32m File /tmp should be directory\e[0m
|
||||
\e[32m \xE2\x9C\x94 File /tmp should be directory\e[0m
|
||||
|
||||
File /tmp
|
||||
\e[32m \xE2\x9C\x94 should be directory\e[0m
|
||||
|
@ -139,4 +139,12 @@ Summary: \e[32m2 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m
|
|||
"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'given a profile with an anonymous describe block' do
|
||||
let(:out) { inspec('exec ' + failure_control) }
|
||||
|
||||
it 'prints the exception message when a test has a syntax error' do
|
||||
out.stdout.must_include "undefined method `should_nota' "
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
11
test/unit/mock/profiles/failures/controls/failures.rb
Normal file
11
test/unit/mock/profiles/failures/controls/failures.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# encoding: utf-8
|
||||
# copyright: 2015, Chef Software, Inc.
|
||||
# license: All rights reserved
|
||||
|
||||
title '/tmp profile'
|
||||
|
||||
# you can also use plain tests
|
||||
describe file('/tmp') do
|
||||
it { should be_directory }
|
||||
it { should_nota be_directory }
|
||||
end
|
Loading…
Reference in a new issue