Class: ChefSpec::Batali

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/batali/chefspec.rb

Instance Method Summary collapse

Constructor Details

#initializeBatali



16
17
18
# File 'lib/batali/chefspec.rb', line 16

def initialize
  @vendor_path = Dir.mktmpdir
end

Instance Method Details

#setup!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/batali/chefspec.rb', line 20

def setup!
  output = ''
  begin
    ::Batali::Command::Update.new(
      Smash.new(
        :file => File.join(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!Object



47
48
49
50
51
# File 'lib/batali/chefspec.rb', line 47

def teardown!
  if(File.directory?(@vendor_path))
    FileUtils.rm_rf(@vendor_path)
  end
end