diff --git a/lib/inspec/dsl_shared.rb b/lib/inspec/dsl_shared.rb index 331df2970..2a610e463 100644 --- a/lib/inspec/dsl_shared.rb +++ b/lib/inspec/dsl_shared.rb @@ -23,9 +23,11 @@ module Inspec # context that provides the correct plane to evaluate all required files to. # It will ensure that embedded calls to `require` still call this # method and get loaded from their correct paths. - return __inspec_binding.eval(content, path, line) if defined?(__inspec_binding) - - eval(content, TOPLEVEL_BINDING, path, line) # rubocop:disable Security/Eval + if defined?(__inspec_binding) + __inspec_binding.eval(content, path, line) + else + eval(content, TOPLEVEL_BINDING, path, line) # rubocop:disable Security/Eval + end end end end