mirror of
https://github.com/inspec/inspec
synced 2024-11-22 20:53:11 +00:00
Respond to @clintoncwolfe's feedback
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This commit is contained in:
parent
a6f74a33b2
commit
7134989eba
3 changed files with 8 additions and 12 deletions
|
@ -39,11 +39,9 @@ module Inspec
|
|||
|
||||
# Create the transport backend with aggregated resources.
|
||||
#
|
||||
# @param [Hash] config for the transport backend
|
||||
# @param [Inspec::Config] config for the transport backend
|
||||
# @return [TransportBackend] enriched transport instance
|
||||
def self.create(config) # rubocop:disable Metrics/AbcSize
|
||||
config = Inspec::Config.new(config) if config.is_a?(Hash)
|
||||
|
||||
train_credentials = config.unpack_train_credentials
|
||||
transport_name = Train.validate_backend(train_credentials)
|
||||
transport = Train.create(transport_name, train_credentials)
|
||||
|
|
|
@ -103,7 +103,7 @@ module InspecPlugins
|
|||
def create_profile_object
|
||||
@profile = Inspec::Profile.for_target(
|
||||
path,
|
||||
backend: Inspec::Backend.create(target: 'mock://'),
|
||||
backend: Inspec::Backend.create(Inspec::Config.mock),
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,11 +6,6 @@ describe 'Backend' do # rubocop:disable Metrics/BlockLength
|
|||
let(:backend) { Inspec::Backend.create(Inspec::Config.mock) }
|
||||
|
||||
describe 'create' do # rubocop:disable Metrics/BlockLength
|
||||
it 'accepts a Hash' do
|
||||
backend_from_hash = Inspec::Backend.create(backend: 'mock')
|
||||
backend_from_hash.is_a?(Inspec::Backend::Base).must_equal true
|
||||
end
|
||||
|
||||
it 'accepts an Inspec::Config' do
|
||||
backend.is_a?(Inspec::Backend::Base).must_equal true
|
||||
end
|
||||
|
@ -36,11 +31,13 @@ describe 'Backend' do # rubocop:disable Metrics/BlockLength
|
|||
end
|
||||
|
||||
it 'enables/disables caching based on `config[:backend_cache]`' do
|
||||
cache_enabled_backend = Inspec::Backend.create(backend_cache: true)
|
||||
cache_enabled_config = Inspec::Config.new(backend_cache: true)
|
||||
cache_enabled_backend = Inspec::Backend.create(cache_enabled_config)
|
||||
cache_enabled_backend.backend.cache_enabled?(:file).must_equal true
|
||||
cache_enabled_backend.backend.cache_enabled?(:command).must_equal true
|
||||
|
||||
cache_disabled_backend = Inspec::Backend.create(backend_cache: false)
|
||||
cache_disabled_config = Inspec::Config.new(backend_cache: false)
|
||||
cache_disabled_backend = Inspec::Backend.create(cache_disabled_config)
|
||||
cache_disabled_backend.backend.cache_enabled?(:file).must_equal false
|
||||
cache_disabled_backend.backend.cache_enabled?(:command).must_equal false
|
||||
end
|
||||
|
@ -51,7 +48,8 @@ describe 'Backend' do # rubocop:disable Metrics/BlockLength
|
|||
end
|
||||
|
||||
it 'disables caching when `config[:debug_shell]` is true' do
|
||||
debug_shell_backend = Inspec::Backend.create(debug_shell: true)
|
||||
debug_shell_config = Inspec::Config.new(debug_shell: true)
|
||||
debug_shell_backend = Inspec::Backend.create(debug_shell_config)
|
||||
debug_shell_backend.backend.cache_enabled?(:file).must_equal false
|
||||
debug_shell_backend.backend.cache_enabled?(:command).must_equal false
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue