Module: Foodtaster::RSpec::ExampleMethods

Defined in:
lib/foodtaster/rspec/example_methods.rb

Defined Under Namespace

Classes: ChefConfig

Instance Method Summary collapse

Instance Method Details

#get_vm(vm_name) ⇒ Object



4
5
6
7
8
# File 'lib/foodtaster/rspec/example_methods.rb', line 4

def get_vm(vm_name)
  Foodtaster::Vm.get(vm_name).tap do |vm|
    vm.prepare unless vm.prepared?
  end
end

#rerun_chef_on(vm_name) ⇒ Object Also known as: repeat_chef_run

Raises:

  • (RuntimeError)


21
22
23
24
25
# File 'lib/foodtaster/rspec/example_methods.rb', line 21

def rerun_chef_on(vm_name)
  raise RuntimeError, "No previous Chef run was made" unless @previous_chef_config
  vm = get_vm(vm_name)
  vm.run_chef(@previous_chef_config)
end

#run_chef_on(vm_name, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/foodtaster/rspec/example_methods.rb', line 10

def run_chef_on(vm_name, &block)
  chef_config = ChefConfig.new
  instance_exec chef_config, &block
  chef_config_as_hash = chef_config.to_hash

  @previous_chef_config = chef_config_as_hash

  vm = get_vm(vm_name)
  vm.run_chef(chef_config_as_hash)
end