Mitigate trivial warning output on test (#2872)

* Mitigate trivial warning on test by initializing
Also fixes passing a ambiguous argument.
* Mitigate trivial warning by removing redundant method

Signed-off-by: ERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com>
This commit is contained in:
eramoto 2018-03-29 00:22:01 +09:00 committed by Jared Quick
parent a5ff79d308
commit 53a53820cf
10 changed files with 19 additions and 32 deletions

View file

@ -31,6 +31,7 @@ module Habitat
def initialize(path, options = {}) def initialize(path, options = {})
@path = path @path = path
@options = options @options = options
@cli_config = nil
log_level = options.fetch('log_level', 'info') log_level = options.fetch('log_level', 'info')
Habitat::Log.level(log_level.to_sym) Habitat::Log.level(log_level.to_sym)

View file

@ -115,6 +115,9 @@ module Inspec
@runner_context = @runner_context =
options[:profile_context] || options[:profile_context] ||
Inspec::ProfileContext.for_profile(self, @backend, @attr_values) Inspec::ProfileContext.for_profile(self, @backend, @attr_values)
@supports_platform = metadata.supports_platform?(@backend)
@supports_runtime = metadata.supports_runtime?
end end
def name def name

View file

@ -38,6 +38,7 @@ module Inspec
# in the transitive dependency tree of the loaded profile. # in the transitive dependency tree of the loaded profile.
@resource_registry = Inspec::Resource.new_registry @resource_registry = Inspec::Resource.new_registry
@library_eval_context = Inspec::LibraryEvalContext.create(@resource_registry, @require_loader) @library_eval_context = Inspec::LibraryEvalContext.create(@resource_registry, @require_loader)
@current_load = nil
end end
def dependencies def dependencies

View file

@ -17,8 +17,6 @@ module Inspec::Resources
filter = FilterTable.create filter = FilterTable.create
filter.add_accessor(:where) filter.add_accessor(:where)
.add_accessor(:entries) .add_accessor(:entries)
.add_accessor(:has_data_disks?)
.add_accessor(:count)
.add(:exists?) { |x| !x.entries.empty? } .add(:exists?) { |x| !x.entries.empty? }
.add(:disk, field: :disk) .add(:disk, field: :disk)
.add(:number, field: :number) .add(:number, field: :number)

View file

@ -74,6 +74,7 @@ module Inspec::Resources
@http_method = http_method @http_method = http_method
@url = url @url = url
@opts = opts @opts = opts
@response = nil
end end
private private
@ -152,6 +153,7 @@ module Inspec::Resources
'curl is not available on the target machine' 'curl is not available on the target machine'
end end
@ran_curl = false
@inspec = inspec @inspec = inspec
super(http_method, url, opts) super(http_method, url, opts)
end end

View file

@ -34,7 +34,7 @@ module Inspec::Resources
read_content read_content
end end
%w{compiler_info error_log_path http_client_body_temp_path http_fastcgi_temp_path http_log_path http_proxy_temp_path http_scgi_temp_path http_uwsgi_temp_path lock_path modules_path openssl_version prefix sbin_path service support_info version}.each do |property| %w{error_log_path http_client_body_temp_path http_fastcgi_temp_path http_log_path http_proxy_temp_path http_scgi_temp_path http_uwsgi_temp_path lock_path modules_path prefix sbin_path service version}.each do |property|
define_method(property.to_sym) do define_method(property.to_sym) do
@params[property.to_sym] @params[property.to_sym]
end end

View file

@ -22,7 +22,6 @@ module Inspec::Resources
end end
" "
attr_reader :content
def initialize(env = nil) def initialize(env = nil)
@osenv = env @osenv = env
end end

View file

@ -180,6 +180,7 @@ module FilterTable
def initialize def initialize
@accessors = [] @accessors = []
@connectors = {} @connectors = {}
@resource = nil
end end
def connect(resource, table_accessor) # rubocop:disable Metrics/AbcSize def connect(resource, table_accessor) # rubocop:disable Metrics/AbcSize

View file

@ -230,7 +230,7 @@ describe Inspec::Reporters::CLI do
it 'confirm controls' do it 'confirm controls' do
result = report.send(:anonymous_controls_from_profile, profile) result = report.send(:anonymous_controls_from_profile, profile)
result.count.must_equal 3 result.count.must_equal 3
result.first[:id].must_match /generated/ result.first[:id].must_match(/generated/)
end end
end end

View file

@ -29,14 +29,14 @@ class AwsS3BucketConstructor < Minitest::Test
end end
end end
#=============================================================================#
# Search / Recall
#=============================================================================#
class AwsS3BucketPropertiesTest < Minitest::Test class AwsS3BucketPropertiesTest < Minitest::Test
def setup def setup
AwsS3Bucket::BackendFactory.select(AwsMSBSB::Basic) AwsS3Bucket::BackendFactory.select(AwsMSBSB::Basic)
end end
#===========================================================================#
# Search / Recall
#===========================================================================#
def test_recall_no_match_is_no_exception def test_recall_no_match_is_no_exception
refute AwsS3Bucket.new('NonExistentBucket').exists? refute AwsS3Bucket.new('NonExistentBucket').exists?
end end
@ -46,17 +46,10 @@ class AwsS3BucketPropertiesTest < Minitest::Test
end end
# No need to handle multiple hits; S3 bucket names are globally unique. # No need to handle multiple hits; S3 bucket names are globally unique.
end
#=============================================================================#
# Properties
#=============================================================================#
class AwsS3BucketPropertiesTest < Minitest::Test
def setup
AwsS3Bucket::BackendFactory.select(AwsMSBSB::Basic)
end
#===========================================================================#
# Properties
#===========================================================================#
#---------------------Bucket Name----------------------------# #---------------------Bucket Name----------------------------#
def test_property_bucket_name def test_property_bucket_name
assert_equal('public', AwsS3Bucket.new('public').bucket_name) assert_equal('public', AwsS3Bucket.new('public').bucket_name)
@ -143,17 +136,9 @@ class AwsS3BucketPropertiesTest < Minitest::Test
assert_empty(bucket_policy) assert_empty(bucket_policy)
end end
end #===========================================================================#
# Test Matchers
#=============================================================================# #===========================================================================#
# Test Matchers
#=============================================================================#
class AwsS3BucketPropertiesTest < Minitest::Test
def setup
AwsS3Bucket::BackendFactory.select(AwsMSBSB::Basic)
end
def test_be_public_public_acl def test_be_public_public_acl
assert(AwsS3Bucket.new('public').public?) assert(AwsS3Bucket.new('public').public?)
end end
@ -163,9 +148,6 @@ class AwsS3BucketPropertiesTest < Minitest::Test
def test_be_public_private_acl def test_be_public_private_acl
refute(AwsS3Bucket.new('private').public?) refute(AwsS3Bucket.new('private').public?)
end end
def test_be_public_public_acl
assert(AwsS3Bucket.new('public').public?)
end
def test_has_access_logging_enabled_positive def test_has_access_logging_enabled_positive
assert(AwsS3Bucket.new('public').has_access_logging_enabled?) assert(AwsS3Bucket.new('public').has_access_logging_enabled?)