Class: Souschef::Testkitchen

Inherits:
Object
  • Object
show all
Defined in:
lib/souschef/testkitchen.rb,
lib/souschef/testkitchen/docker.rb,
lib/souschef/testkitchen/solusvm.rb,
lib/souschef/testkitchen/virtualbox.rb

Overview

TestKitchen generator

Defined Under Namespace

Classes: Docker, Solusvm, Virtualbox

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Testkitchen

Returns a new instance of Testkitchen.



10
11
12
13
14
15
# File 'lib/souschef/testkitchen.rb', line 10

def initialize(opts)
  @opts = opts
  @cookbook = opts[:cookbook]
  @file = kitchen_driver_file
  
end

Instance Attribute Details

#cookbookObject

Returns the value of attribute cookbook.



8
9
10
# File 'lib/souschef/testkitchen.rb', line 8

def cookbook
  @cookbook
end

#filesObject

Returns the value of attribute files.



8
9
10
# File 'lib/souschef/testkitchen.rb', line 8

def files
  @files
end

#metadataObject

Returns the value of attribute metadata.



8
9
10
# File 'lib/souschef/testkitchen.rb', line 8

def 
  @metadata
end

#optsObject

Returns the value of attribute opts.



8
9
10
# File 'lib/souschef/testkitchen.rb', line 8

def opts
  @opts
end

Instance Method Details

#configureObject

Public - Write down TestKitchen configuration

Returns nil



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/souschef/testkitchen.rb', line 20

def configure
  if @opts[:docker]
    Souschef::Print.info 'Creating Docker configuration .kitchen.local.yml'
    write(:docker, Souschef::Testkitchen::Docker.new(@cookbook).yaml)
  end
  if @opts[:solusvm]
    Souschef::Print.info 'Creating SolusVM configuraton .kitchen.local.yml'
    write(:solusvm, Souschef::Testkitchen::Solusvm.new(@cookbook).yaml)
  end

  Souschef::Print.info 'Creating Vagrant configuration in .kitchen.yml'
  write(:virtualbox, Souschef::Testkitchen::Virtualbox.new(@cookbook).yaml)
end

#setupObject

Public - Copy the already generated files from the data/ directory

Returns nil



37
38
39
40
41
42
# File 'lib/souschef/testkitchen.rb', line 37

def setup
  templates = ['default']
  templates << @opts[:testkitchen] if @opts[:testkitchen]

  templates.each { |type| create_file(type) }
end