mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Fixed file resource raising UndefinedMethod on source_path
This is a first pass at fixing the failure found by @scottvidmar where file resource was raising undefined_method on nil. The problem was that the initialize method for file was not being called at all because Resource#initialize was returning early without reporting anything. This fix causes a failure in test/functional/inspec_exec_test.rb where it is testing a similar scenario but for some reason the unsupported resources get reported. We need to figure that part out, but in the meantime this will at least report an error at the root cause rather than down the road. Fixes #4208 Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
parent
823c858073
commit
7273a7380f
2 changed files with 12 additions and 5 deletions
|
@ -87,7 +87,15 @@ module Inspec
|
|||
@__backend_runner__ = backend
|
||||
@__resource_name__ = name
|
||||
|
||||
check_supports unless @supports.nil? # this has side effects
|
||||
# check resource supports
|
||||
supported = @supports ? check_supports : true # check_supports has side effects!
|
||||
test_backend = defined?(Train::Transports::Mock::Connection) && backend.backend.class == Train::Transports::Mock::Connection
|
||||
# raise unless we are supported or in test
|
||||
unless supported || test_backend
|
||||
msg = "Unsupported resource/backend combination: %s / %s. Exiting." %
|
||||
[name, backend.platform.name]
|
||||
raise ArgumentError, msg
|
||||
end
|
||||
|
||||
# call the resource initializer
|
||||
begin
|
||||
|
|
|
@ -297,10 +297,9 @@ Test Summary: 0 successful, 0 failures, 0 skipped
|
|||
let(:out) { inspec("exec " + File.join(profile_path, "aws-profile")) }
|
||||
it "exits with an error" do
|
||||
skip if ENV["NO_AWS"]
|
||||
|
||||
stdout.must_include "Resource `aws_iam_users` is not supported on platform"
|
||||
stdout.must_include "Resource `aws_iam_access_keys` is not supported on platform"
|
||||
stdout.must_include "Resource `aws_s3_bucket` is not supported on platform"
|
||||
stdout.must_include "Unsupported resource/backend combination: aws_iam_users"
|
||||
stdout.must_include "Unsupported resource/backend combination: aws_iam_access_keys"
|
||||
stdout.must_include "Unsupported resource/backend combination: aws_s3_bucket"
|
||||
stdout.must_include "3 failures"
|
||||
|
||||
assert_exit_code 100, out
|
||||
|
|
Loading…
Reference in a new issue