Merge pull request #4670 from inspec/zenspider/gem-resource

Pre-load the gem resource to override the global gem method.
This commit is contained in:
Ryan Davis 2019-11-05 16:32:48 -08:00 committed by GitHub
commit 4ed9305535
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -110,3 +110,5 @@ end
# Many resources use FilterTable.
require "inspec/utils/filter"
# conflicts with global `gem` method so we need to pre-load this.
require "inspec/resources/gem"

View file

@ -2,7 +2,7 @@ require "inspec/resources/command"
module Inspec::Resources
class GemPackage < Inspec.resource(1)
name "gem"
name "gem" # TODO: rename to "rubygem" and provide alias
supports platform: "unix"
supports platform: "windows"
desc "Use the gem InSpec audit resource to test if a global gem package is installed."
@ -17,11 +17,12 @@ module Inspec::Resources
def initialize(package_name, gem_binary = nil)
@package_name = package_name
@gem_binary = case gem_binary
@gem_binary = case gem_binary # TODO: no. this is not right
when nil
"gem"
when :chef
if inspec.os.windows?
# TODO: what about chef-dk or other installs?
'c:\opscode\chef\embedded\bin\gem.bat'
else
"/opt/chef/embedded/bin/gem"