From 5b6fdf9a98172827db8000b153094331beac4616 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Mon, 4 Nov 2019 13:24:02 -0800 Subject: [PATCH] Pre-load the gem resource to override the global gem method. This seems problematic to me in general. We should probably not override global methods. Renaming this to rubygem and providing a deprecated alias seems like the right thing to do. Signed-off-by: Ryan Davis --- lib/inspec/resource.rb | 2 ++ lib/inspec/resources/gem.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/inspec/resource.rb b/lib/inspec/resource.rb index b30fcff5a..05ab6c952 100644 --- a/lib/inspec/resource.rb +++ b/lib/inspec/resource.rb @@ -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" diff --git a/lib/inspec/resources/gem.rb b/lib/inspec/resources/gem.rb index a5b2508b6..641465c7d 100644 --- a/lib/inspec/resources/gem.rb +++ b/lib/inspec/resources/gem.rb @@ -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."