mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
Update test code regarding input marshalling
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
00d497fd09
commit
0023906812
1 changed files with 7 additions and 5 deletions
|
@ -34,15 +34,17 @@ describe Inspec::Input do
|
|||
|
||||
ruby_code = input.to_ruby
|
||||
ruby_code.must_include "attr_application_port = " # Should assign to a var
|
||||
ruby_code.must_include "attribute('application_port'" # Should have the DSL call
|
||||
ruby_code.must_include "value: 80"
|
||||
ruby_code.must_include "default: 80"
|
||||
# Should have the DSL call. This should be attribute(), not input(), for the
|
||||
# foreseeable future, to maintain backwards compatibility.
|
||||
ruby_code.must_include "attribute('application_port'"
|
||||
ruby_code.must_include 'value: 80'
|
||||
ruby_code.must_include 'default: 80'
|
||||
ruby_code.must_include "description: 'The port my application uses'"
|
||||
|
||||
# Try to eval the code to verify that the generated code was valid ruby.
|
||||
# Note that the attribute() method is part of the DSL, so we need to
|
||||
# Note that the input() method is part of the DSL, so we need to
|
||||
# alter the call into something that can respond - the constructor will do
|
||||
ruby_code_for_eval = ruby_code.sub(/attribute\(/, "Inspec::Input.new(")
|
||||
ruby_code_for_eval = ruby_code.sub(/input\(/,'Inspec::Input.new(')
|
||||
|
||||
# This will throw exceptions if there is a problem
|
||||
new_attr = eval(ruby_code_for_eval) # rubocop:disable Security/Eval # Could use ripper!
|
||||
|
|
Loading…
Reference in a new issue