Merge pull request #1455 from chef/ap/tests-setter

Allow setting of the tests array
This commit is contained in:
Alex Pop 2017-02-03 16:00:09 +00:00 committed by GitHub
commit d7e2edc8bb
2 changed files with 28 additions and 1 deletions

View file

@ -2,7 +2,8 @@
module Inspec
class EachLoop < List
attr_reader :tests, :variables
attr_reader :variables
attr_accessor :tests
def initialize
super
@tests = []

View file

@ -196,6 +196,32 @@ end
'.strip
end
it 'loops a describe.one block, ooooooo!' do
res = Inspec::EachLoop.new
res.qualifier.push(['(1..5)'])
# already defined in the let block:
obj1.matcher = 'eq entity'
obj2.matcher = 'eq entity'
obj1.remove_expectation
obj2.remove_expectation
or_obj = Inspec::OrTest.new([obj1,obj2])
res.tests = [or_obj]
res.to_ruby.must_equal '
(1..5).each do |entry|
describe.one do
describe command("ls /etc") do
its("exit_status") { should eq entity }
end
describe command("ls /etc") do
its("exit_status") { should_not eq entity }
end
end
end
'.strip
end
it 'constructs a control' do
control = Inspec::Control.new
control.add_test(obj1)