module ChefSpec::Extensions::Chef::Resource::ClassMethods
Public Instance Methods
action(sym, description: nil, &block)
click to toggle source
Calls superclass method
# File lib/chefspec/extensions/chef/resource.rb, line 147 def action(sym, description: nil, &block) inject_actions(sym) super(sym, &block) end
allowed_actions(*actions)
click to toggle source
Calls superclass method
# File lib/chefspec/extensions/chef/resource.rb, line 152 def allowed_actions(*actions) inject_actions(*actions) unless actions.empty? super end
allowed_actions=(value)
click to toggle source
Calls superclass method
# File lib/chefspec/extensions/chef/resource.rb, line 157 def allowed_actions=(value) inject_actions(*Array(value)) super end
provides(name, **options, &block)
click to toggle source
Calls superclass method
# File lib/chefspec/extensions/chef/resource.rb, line 141 def provides(name, **options, &block) provides_names << name unless provides_names.include?(name) inject_actions(*allowed_actions) super end
provides_names()
click to toggle source
XXX: kind of a crappy way to find all the names of a resource
# File lib/chefspec/extensions/chef/resource.rb, line 129 def provides_names @provides_names ||= [] end
resource_name(name = ::Chef::NOT_PASSED)
click to toggle source
Calls superclass method
# File lib/chefspec/extensions/chef/resource.rb, line 133 def resource_name(name = ::Chef::NOT_PASSED) unless name == ::Chef::NOT_PASSED provides_names << name unless provides_names.include?(name) inject_actions(*allowed_actions) end super end
Private Instance Methods
inject_actions(*actions)
click to toggle source
# File lib/chefspec/extensions/chef/resource.rb, line 172 def inject_actions(*actions) provides_names.each do |resource_name| next unless resource_name ChefSpec.define_matcher(resource_name) actions.each do |action| inject_method(:"#{action}_#{resource_name}", resource_name, action) if action == :create_if_missing inject_method(:"create_#{resource_name}_if_missing", resource_name, action) end end end end
inject_method(method, resource_name, action)
click to toggle source
# File lib/chefspec/extensions/chef/resource.rb, line 164 def inject_method(method, resource_name, action) unless ChefSpec::API.respond_to?(method) ChefSpec::API.send(:define_method, method) do |name| ChefSpec::Matchers::ResourceMatcher.new(resource_name, action, name) end end end