class ChefSpec::Batali

Batali integration class

Public Class Methods

new() click to toggle source

Create new instance

# File lib/batali/chefspec.rb, line 18
def initialize
  @vendor_path = Utility.clean_path(Dir.mktmpdir)
end

Public Instance Methods

setup!() click to toggle source

Setup the environment (load cookbooks)

# File lib/batali/chefspec.rb, line 23
def setup!
  output = ""
  begin
    ::Batali::Command::Update.new(
      Smash.new(
        :file => Utility.join_path(Dir.pwd, "Batali"),
        :path => @vendor_path,
        :update => {
          :install => true,
        },
        :ui => Bogo::Ui.new(
          :app_name => "Batali",
          :output_to => StringIO.new(output),
        ),
      ),
      []
    ).execute!
    RSpec.configure do |config|
      config.cookbook_path = @vendor_path
    end
  rescue => e
    $stderr.puts "Batali failure - #{e.class}: #{e.message}"
    $stderr.puts output
    raise
  end
end
teardown!() click to toggle source

Clean up after complete

# File lib/batali/chefspec.rb, line 51
def teardown!
  if File.directory?(@vendor_path)
    FileUtils.rm_rf(@vendor_path)
  end
end