module ChefSpec::API::Core
Public Instance Methods
chef_runner_class()
click to toggle source
Class of runner to use.
@abstract @return [Class]
# File lib/chefspec/api/core.rb, line 59 def chef_runner_class ChefSpec::SoloRunner end
chef_runner_instance()
click to toggle source
Create an instance of the runner.
This should only be used in cases where the ‘let()` cache would be a problem.
@return [ChefSpec::SoloRunner]
# File lib/chefspec/api/core.rb, line 68 def chef_runner_instance chef_runner_class.new(chef_runner_options) end
chef_runner_options()
click to toggle source
Compute the options for the runner.
@abstract @return [Hash<Symbol, Object>]
# File lib/chefspec/api/core.rb, line 37 def chef_runner_options options = { step_into: chefspec_ancestor_gather([], :step_into) { |memo, val| memo | val }, default_attributes: chefspec_default_attributes, normal_attributes: chefspec_normal_attributes, override_attributes: chefspec_override_attributes, automatic_attributes: chefspec_automatic_attributes, spec_declaration_locations: self.class.declaration_locations.last[0], } # Only specify these if set in the example so we don't override the # global settings. options[:platform] = chefspec_platform if chefspec_platform options[:version] = chefspec_platform_version if chefspec_platform_version # Merge in any final overrides. options.update(chefspec_attributes(:chefspec_options).symbolize_keys) options end
chefspec_ancestor_gather(start, method, &block)
click to toggle source
Helper method for some of the nestable test value methods like {ClassMethods#default_attributes} and {ClassMethods#step_into}.
@api private @param start [Object] Initial value for the reducer. @param method [Symbol] Name of the group-level method to call on each
ancestor.
@param block [Proc] Reducer callable. @return [Object]
# File lib/chefspec/api/core.rb, line 87 def chefspec_ancestor_gather(start, method, &block) candidate_ancestors = self.class.ancestors.select { |cls| cls.respond_to?(method) && cls != ChefSpec::API::Core } candidate_ancestors.reverse.inject(start) do |memo, cls| block.call(memo, cls.send(method)) end end
chefspec_attributes(method)
click to toggle source
Special case of {#chefspec_ancestor_gather} because we do it four times.
@api private @param method [Symbol] Name of the group-level method to call on each
ancestor.
@return [Mash]
# File lib/chefspec/api/core.rb, line 100 def chefspec_attributes(method) chefspec_ancestor_gather(Mash.new, method) do |memo, val| Chef::Mixin::DeepMerge.merge(memo, val) end end