mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
Remove class var for testing, replace with tramp data
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
212fe36b76
commit
48e2188047
3 changed files with 8 additions and 23 deletions
|
@ -6,14 +6,8 @@ module Inspec
|
||||||
class Deprecator
|
class Deprecator
|
||||||
attr_reader :config, :groups
|
attr_reader :config, :groups
|
||||||
|
|
||||||
# This is used only in functional testing
|
|
||||||
def self.class_test_cfg_io(io)
|
|
||||||
@@test_cfg_io = io # rubocop: disable Style/ClassVars
|
|
||||||
end
|
|
||||||
|
|
||||||
def initialize(opts = {})
|
def initialize(opts = {})
|
||||||
@@test_cfg_io ||= nil # rubocop: disable Style/ClassVars
|
@config = Inspec::Deprecation::ConfigFile.new(opts[:config_io])
|
||||||
@config = Inspec::Deprecation::ConfigFile.new(opts[:config_io] || @@test_cfg_io)
|
|
||||||
@groups = @config.groups
|
@groups = @config.groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ require 'utils/deprecation/deprecator'
|
||||||
|
|
||||||
module Inspec
|
module Inspec
|
||||||
def self.deprecate(group, msg, opts = {})
|
def self.deprecate(group, msg, opts = {})
|
||||||
deprecator = opts.delete(:deprecator) || Inspec::Deprecation::Deprecator.new
|
config_io = opts.delete(:config_io)
|
||||||
|
deprecator = Inspec::Deprecation::Deprecator.new(config_io: config_io)
|
||||||
deprecator.handle_deprecation(group, msg, opts)
|
deprecator.handle_deprecation(group, msg, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,41 +18,31 @@ class DeprecationTester < Inspec.resource(1)
|
||||||
EOC
|
EOC
|
||||||
|
|
||||||
def fail_me
|
def fail_me
|
||||||
Inspec::Deprecation::Deprecator.class_test_cfg_io(StringIO.new(DEPRECATION_CFG))
|
Inspec.deprecate(:a_group_that_will_fail, 'This should fail', config_io: StringIO.new(DEPRECATION_CFG))
|
||||||
|
|
||||||
Inspec.deprecate(:a_group_that_will_fail, 'This should fail')
|
|
||||||
|
|
||||||
'fail_me_return_value'
|
'fail_me_return_value'
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit_me_default_code
|
def exit_me_default_code
|
||||||
Inspec::Deprecation::Deprecator.class_test_cfg_io(StringIO.new(DEPRECATION_CFG))
|
Inspec.deprecate(:a_group_that_will_exit, 'This should exit', config_io: StringIO.new(DEPRECATION_CFG))
|
||||||
|
|
||||||
Inspec.deprecate(:a_group_that_will_exit, 'This should exit')
|
|
||||||
|
|
||||||
'exit_me_return_value'
|
'exit_me_return_value'
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit_me_explicit_code
|
def exit_me_explicit_code
|
||||||
Inspec::Deprecation::Deprecator.class_test_cfg_io(StringIO.new(DEPRECATION_CFG))
|
Inspec.deprecate(:a_group_that_will_exit_with_a_code, 'This should exit', config_io: StringIO.new(DEPRECATION_CFG))
|
||||||
|
|
||||||
Inspec.deprecate(:a_group_that_will_exit_with_a_code, 'This should exit')
|
|
||||||
|
|
||||||
'exit_me_return_value'
|
'exit_me_return_value'
|
||||||
end
|
end
|
||||||
|
|
||||||
def ignore_me
|
def ignore_me
|
||||||
Inspec::Deprecation::Deprecator.class_test_cfg_io(StringIO.new(DEPRECATION_CFG))
|
Inspec.deprecate(:an_ignored_group, 'This should be ignored', config_io: StringIO.new(DEPRECATION_CFG))
|
||||||
|
|
||||||
Inspec.deprecate(:an_ignored_group, 'This should be ignored')
|
|
||||||
|
|
||||||
'ignore_me_return_value'
|
'ignore_me_return_value'
|
||||||
end
|
end
|
||||||
|
|
||||||
def warn_me
|
def warn_me
|
||||||
Inspec::Deprecation::Deprecator.class_test_cfg_io(StringIO.new(DEPRECATION_CFG))
|
Inspec.deprecate(:a_group_that_will_warn, 'This should warn', config_io: StringIO.new(DEPRECATION_CFG))
|
||||||
|
|
||||||
Inspec.deprecate(:a_group_that_will_warn, 'This should warn')
|
|
||||||
|
|
||||||
'warn_me_return_value'
|
'warn_me_return_value'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue