Replace most mentions of Attribute (titlecase) in lib and test

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-02-11 23:13:50 -05:00
parent ce99624095
commit 4f361bfc56
8 changed files with 18 additions and 18 deletions

View file

@ -27,7 +27,7 @@ module Inspec
# allow attributes to be accessed within control blocks
define_method :attribute do |name|
Inspec::AttributeRegistry.find_attribute(name, profile_id).value
Inspec::InputRegistry.find_input(name, profile_id).value
end
# Support for Control DSL plugins.
@ -167,12 +167,12 @@ module Inspec
profile_context_owner.register_rule(control, &block) unless control.nil?
end
# method for attributes; import attribute handling
# method for inputs; import input handling
define_method :attribute do |name, options = nil|
if options.nil?
Inspec::AttributeRegistry.find_attribute(name, profile_id).value
Inspec::InputRegistry.find_input(name, profile_id).value
else
profile_context_owner.register_attribute(name, options)
profile_context_owner.register_input(name, options)
end
end

View file

@ -3,8 +3,8 @@
module Inspec
module Exceptions
class AttributesFileDoesNotExist < ArgumentError; end
class AttributesFileNotReadable < ArgumentError; end
class InputsFileDoesNotExist < ArgumentError; end
class InputsFileNotReadable < ArgumentError; end
class ResourceFailed < StandardError; end
class ResourceSkipped < StandardError; end
class SecretsBackendNotFound < ArgumentError; end

View file

@ -1,7 +1,7 @@
# encoding: utf-8
module Inspec
autoload :Attribute, 'inspec/objects/input'
autoload :Input, 'inspec/objects/input'
autoload :Tag, 'inspec/objects/tag'
autoload :Control, 'inspec/objects/control'
autoload :Describe, 'inspec/objects/describe'

View file

@ -135,7 +135,7 @@ module Inspec
@runner_context.register_attribute(name, attr_dup)
end
elsif metadata.params.key?(:attributes)
Inspec::Log.warn 'Attributes must be defined as an Array. Skipping current definition.'
Inspec::Log.warn 'Inputs must be defined as an Array. Skipping current definition.'
end
end

View file

@ -34,8 +34,8 @@ module Inspec
@control_subcontexts = []
@lib_subcontexts = []
@require_loader = ::Inspec::RequireLoader.new
Inspec::AttributeRegistry.register_profile_alias(@profile_id, @profile_name) if @profile_id != @profile_name
@attributes = Inspec::AttributeRegistry.list_attributes_for_profile(@profile_id)
Inspec::InputRegistry.register_profile_alias(@profile_id, @profile_name) if @profile_id != @profile_name
@attributes = Inspec::InputRegistry.list_inputs_for_profile(@profile_id)
# A local resource registry that only contains resources defined
# in the transitive dependency tree of the loaded profile.
@resource_registry = Inspec::Resource.new_registry
@ -188,8 +188,8 @@ module Inspec
end
def register_attribute(name, options = {})
# we need to return an attribute object, to allow dermination of default values
attribute = Inspec::AttributeRegistry.register_attribute(name, @profile_id, options)
# we need to return an attribute object, to allow dermination of values
attribute = Inspec::InputRegistry.register_attribute(name, @profile_id, options)
attribute.value = @conf['attributes'][name] unless @conf['attributes'].nil? || @conf['attributes'][name].nil?
attribute.value
end

View file

@ -64,9 +64,9 @@ module Inspec
end
class RSpec::Core::ExampleGroup
# This DSL method allows us to access the values of attributes within InSpec tests
# This DSL method allows us to access the values of inputs within InSpec tests
def attribute(name)
Inspec::AttributeRegistry.find_attribute(name, self.class.metadata[:profile_id]).value
Inspec::InputRegistry.find_input(name, self.class.metadata[:profile_id]).value
end
define_example_method :attribute

View file

@ -291,13 +291,13 @@ module Inspec
def validate_attributes_file_readability!(target)
unless File.exist?(target)
raise Inspec::Exceptions::AttributesFileDoesNotExist,
raise Inspec::Exceptions::InputsFileDoesNotExist,
"Cannot find attributes file '#{target}'. " \
'Check to make sure file exists.'
end
unless File.readable?(target)
raise Inspec::Exceptions::AttributesFileNotReadable,
raise Inspec::Exceptions::InputsFileNotReadable,
"Cannot read attributes file '#{target}'. " \
'Check to make sure file is readable.'
end

View file

@ -38,7 +38,7 @@ describe 'attributes' do
cmd += File.join(inputs_profiles_path, 'metadata-empty')
cmd += ' --no-create-lockfile'
out = inspec(cmd)
out.stdout.must_include 'WARN: Attributes must be defined as an Array. Skipping current definition.'
out.stdout.must_include 'WARN: Inputs must be defined as an Array. Skipping current definition.'
out.exit_status.must_equal 0
end
@ -57,7 +57,7 @@ describe 'attributes' do
cmd += File.join(inputs_profiles_path, 'required')
cmd += ' --no-create-lockfile'
out = inspec(cmd)
out.stderr.must_equal "Attribute 'username' is required and does not have a value.\n"
out.stderr.must_equal "Input 'username' is required and does not have a value.\n"
out.stdout.must_equal ''
out.exit_status.must_equal 1
end