10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/minitest-chef-handler/resources.rb', line 10
def self.register_resource(resource, *required_args)
define_method(resource) do |name, *options|
clazz = ::Chef::Resource.const_get(convert_to_class_name(resource.to_s))
res = clazz.new(name, run_context)
required_args.each do |arg|
res.send(arg, options.first[arg])
end
if Gem::Version.new(::Chef::VERSION) < Gem::Version.new("10.14.0")
provider = ::Chef::Platform.provider_for_resource(res)
else
provider = ::Chef::Platform.provider_for_resource(res, :create)
end
provider.load_current_resource
provider.current_resource
end
end
|