Skip to content

Commit

Permalink
Update test code regarding input marshalling
Browse files Browse the repository at this point in the history
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
  • Loading branch information
clintoncwolfe committed Jun 10, 2019
1 parent 1d3f177 commit 2d15370
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/unit/inputs/input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@

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
# 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) # Could use ripper!
Expand Down

0 comments on commit 2d15370

Please sign in to comment.