Respond to @clintoncwolfe's feedback

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This commit is contained in:
Jerry Aldrich 2019-02-07 10:42:19 -08:00
parent a6f74a33b2
commit 7134989eba
3 changed files with 8 additions and 12 deletions

View file

@ -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)

View file

@ -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

View file

@ -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