Module: ChefSpec::Extensions::Chef::Resource::ClassMethods

Defined in:
lib/chefspec/extensions/chef/resource.rb

Instance Method Summary collapse

Instance Method Details

#action(sym, description: nil, &block) ⇒ Object



147
148
149
150
# 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) ⇒ Object



152
153
154
155
# File 'lib/chefspec/extensions/chef/resource.rb', line 152

def allowed_actions(*actions)
  inject_actions(*actions) unless actions.empty?
  super
end

#allowed_actions=(value) ⇒ Object



157
158
159
160
# File 'lib/chefspec/extensions/chef/resource.rb', line 157

def allowed_actions=(value)
  inject_actions(*Array(value))
  super
end

#provides(name, **options, &block) ⇒ Object



141
142
143
144
145
# 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_namesObject

XXX: kind of a crappy way to find all the names of a resource



129
130
131
# File 'lib/chefspec/extensions/chef/resource.rb', line 129

def provides_names
  @provides_names ||= []
end

#resource_name(name = ::Chef::NOT_PASSED) ⇒ Object



133
134
135
136
137
138
139
# 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