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

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

Instance Method Summary collapse

Instance Method Details

#action(sym, &block) ⇒ Object


143
144
145
146
# File 'lib/chefspec/extensions/chef/resource.rb', line 143

def action(sym, &block)
  inject_actions(sym)
  super
end

#allowed_actions(*actions) ⇒ Object


148
149
150
151
# File 'lib/chefspec/extensions/chef/resource.rb', line 148

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

#allowed_actions=(value) ⇒ Object


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

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

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


137
138
139
140
141
# File 'lib/chefspec/extensions/chef/resource.rb', line 137

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


125
126
127
# File 'lib/chefspec/extensions/chef/resource.rb', line 125

def provides_names
  @provides_names ||= []
end

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


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

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