bugfix: solve warn on uninitialized

@expectation was analyzed without initializeation, leading to ruby errors. fix it

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2017-04-21 23:15:55 +02:00
parent 2eef024c0c
commit f731cbca92

View file

@ -66,13 +66,14 @@ module Inspec
res, xtra = describe_chain
itsy = xtra.nil? ? 'it' : 'its(' + xtra.to_s.inspect + ')'
naughty = @negated ? '_not' : ''
xpect = defined?(@expectation) ? expectation.inspect : ''
if @expectation.class == Regexp
# without this, xpect values like / \/zones\// will not be parsed properly
xpect = "(#{xpect})"
elsif xpect != ''
xpect = ' ' + xpect
end
xpect = if !defined?(@expectation)
''
elsif @expectation.class == Regexp
# without this, xpect values like / \/zones\// will not be parsed properly
"(#{@expectation.inspect})"
elsif xpect != ''
' ' + expectation.inspect
end
format("%sdescribe %s do\n %s { should%s %s%s }\nend",
vars, res, itsy, naughty, matcher, xpect)
end