inspec/test/unit/mock/profiles/profile-with-resource-exceptions/controls/exception_resource.rb
Jerry Aldrich III 43b71ff132 Add non-halting exception support to resources (#2235)
* Add non-halting exception support to resources

This adds two `Inspec::Exceptions` that can be used within resources to
either skip or fail a test without halting execution.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2017-11-06 13:28:53 -05:00

31 lines
898 B
Ruby

# encoding: utf-8
describe exception_resource_test('should raise ResourceSkipped', :skip_me) do
its('value') { should eq 'does not matter' }
end
describe exception_resource_test('should raise ResourceFailed', :fail_me) do
its('value') { should eq 'does not matter' }
end
describe exception_resource_test('should pass') do
its('value') { should eq 'should pass' }
end
describe exception_resource_test('fail inside matcher') do
its('inside_matcher') { should eq 'does not matter' }
end
describe exception_resource_test('skip inside matcher') do
its('inside_matcher') { should eq 'does not matter' }
end
control 'should-work-within-control' do
describe exception_resource_test('should skip', :skip_me) do
its('value') { should eq 'does not matter' }
end
describe exception_resource_test('should fail', :fail_me) do
its('value') { should eq 'does not matter' }
end
end