mirror of
https://github.com/inspec/inspec
synced 2024-11-30 08:30:39 +00:00
Rely on copy of to_hash in objects/input.rb to avoid duplication
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
51812a9e4e
commit
36db8b9a7b
3 changed files with 5 additions and 21 deletions
|
@ -318,21 +318,6 @@ module Inspec
|
|||
!current_value.is_a? NO_VALUE_SET
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------#
|
||||
# Marshalling
|
||||
#--------------------------------------------------------------------------#
|
||||
|
||||
def to_hash
|
||||
as_hash = { name: name, options: {} }
|
||||
%i{description title identifier type required value}.each do |field|
|
||||
val = send(field)
|
||||
next if val.nil?
|
||||
|
||||
as_hash[:options][field] = val
|
||||
end
|
||||
as_hash
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------#
|
||||
# Value Type Coercion
|
||||
#--------------------------------------------------------------------------#
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require "forwardable"
|
||||
require "singleton"
|
||||
require "inspec/input"
|
||||
require "inspec/objects/input"
|
||||
require "inspec/secrets"
|
||||
require "inspec/exceptions"
|
||||
require "inspec/plugin/v2"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require "helper"
|
||||
require "inspec/input"
|
||||
require "inspec/objects/input"
|
||||
|
||||
describe Inspec::Input do
|
||||
let(:opts) { {} }
|
||||
|
@ -32,8 +32,7 @@ describe Inspec::Input do
|
|||
title: "Best input ever",
|
||||
description: "important",
|
||||
type: "Numeric",
|
||||
required: true
|
||||
)
|
||||
required: true)
|
||||
_(input.to_hash).must_equal({
|
||||
name: "test_input",
|
||||
options: {
|
||||
|
@ -41,8 +40,8 @@ describe Inspec::Input do
|
|||
title: "Best input ever",
|
||||
description: "important",
|
||||
type: "Numeric",
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue