Class: Halite::SpecHelper::Runner
- Inherits:
-
ChefSpec::SoloRunner
- Object
- ChefSpec::SoloRunner
- Halite::SpecHelper::Runner
- Defined in:
- lib/halite/spec_helper/runner.rb
Overview
ChefSpec runner class with Halite customizations. This adds attribute options, Halite synthetic cookbook injection, and block-based recipes.
Class Method Summary collapse
Instance Method Summary collapse
- #converge(*recipe_names, &block) ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/halite/spec_helper/runner.rb', line 45 def initialize(={}) super() do |node| # Allow inserting arbitrary attribute data in to the node node.attributes.default = Chef::Mixin::DeepMerge.merge(node.attributes.default, [:default_attributes]) if [:default_attributes] node.attributes.normal = Chef::Mixin::DeepMerge.merge(node.attributes.normal, [:normal_attributes]) if [:normal_attributes] node.attributes.override = Chef::Mixin::DeepMerge.merge(node.attributes.override, [:override_attributes]) if [:override_attributes] # Store the gemspec for later use @halite_gemspec = [:halite_gemspec] end end |
Class Method Details
.converge(*recipe_names, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/halite/spec_helper/runner.rb', line 33 def self.converge(*recipe_names, &block) = if recipe_names.last.is_a?(Hash) # Was called with options recipe_names.pop else {} end new().tap do |instance| instance.converge(*recipe_names, &block) end end |
Instance Method Details
#converge(*recipe_names, &block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/halite/spec_helper/runner.rb', line 56 def converge(*recipe_names, &block) raise Halite::Error.new('Cannot pass both recipe names and a recipe block to converge') if !recipe_names.empty? && block super(*recipe_names) do add_halite_cookbooks(node, @halite_gemspec) if @halite_gemspec if block recipe = Chef::Recipe.new(nil, nil, run_context) recipe.instance_exec(&block) end end end |