inspec/test/unit/mock/profiles/failures/controls/failures.rb

42 lines
1.3 KiB
Ruby
Raw Normal View History

2016-09-01 12:25:56 +00:00
# copyright: 2015, Chef Software, Inc.
2016-09-01 22:54:03 +00:00
title 'failures /tmp profile'
2016-09-01 12:25:56 +00:00
2016-09-01 22:54:03 +00:00
# control, first test passes, second fails
control "tmp-1.0" do # A unique ID for this control
impact 0.7 # The criticality, if this control fails.
title "Create /tmp directory" # A human-readable title
desc "An optional description..." # Describe why this is needed
tag data: "temp data" # A tag allows you to associate key information
tag "security" # to the test
ref "Document A-12", url: 'http://...' # Additional references
describe file('/tmp') do # The actual test
it { should be_directory }
it { should_not be_directory }
end
end
# anonymous describe block, first passes, second is syntax error
2016-09-01 12:25:56 +00:00
describe file('/tmp') do
it { should be_directory }
it { should_nota be_directory }
end
2016-09-01 22:54:03 +00:00
# anonymous describe block, first fails, second passes
describe file('/tmp') do
it { should_not be_directory }
it { should be_directory }
its('mode') { should cmp '01147' }
2016-09-01 22:54:03 +00:00
end
2016-10-05 18:01:24 +00:00
# control, first and second fail, third passes
control 'cmp-1.0' do
title 'Using the cmp matcher for numbers'
describe 7 do
it { should cmp >= 9 }
it { should_not cmp /^\d$/ }
it { should cmp == '7' }
end
end