mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Allow add_test to accept negation (#3586)
* Allow add_test to accept negation This will allow for negated tests to be generated with add_tests. * Fix rubocop violation * Add optional options hash Signed-off-by: Rachel Rice <rrice@chef.io>
This commit is contained in:
parent
45926ef63a
commit
de5b332feb
2 changed files with 22 additions and 2 deletions
|
@ -57,8 +57,8 @@ module Inspec
|
|||
@variables = []
|
||||
end
|
||||
|
||||
def add_test(its, matcher, expectation)
|
||||
test = Inspec::Describe::Test.new(its, matcher, expectation, false)
|
||||
def add_test(its, matcher, expectation, opts = {})
|
||||
test = Inspec::Describe::Test.new(its, matcher, expectation, opts[:negated])
|
||||
tests.push(test)
|
||||
test
|
||||
end
|
||||
|
|
|
@ -127,6 +127,26 @@ end
|
|||
describe resource do
|
||||
its(["explorer", "exe"]) { should cmp 1 }
|
||||
end
|
||||
'.strip
|
||||
end
|
||||
|
||||
it 'is negated' do
|
||||
obj.qualifier = [['resource']]
|
||||
obj.add_test(['explorer', 'exe'], 'cmp', 1, :negated => true)
|
||||
obj.to_ruby.must_equal '
|
||||
describe resource do
|
||||
its(["explorer", "exe"]) { should_not cmp 1 }
|
||||
end
|
||||
'.strip
|
||||
end
|
||||
|
||||
it 'is not negated' do
|
||||
obj.qualifier = [['resource']]
|
||||
obj.add_test(['explorer', 'exe'], 'cmp', 1, :negated => false)
|
||||
obj.to_ruby.must_equal '
|
||||
describe resource do
|
||||
its(["explorer", "exe"]) { should cmp 1 }
|
||||
end
|
||||
'.strip
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue