Module: Cheffish::RSpec::ChefRunSupport

Includes:
ChefZero::RSpec, RepositorySupport
Defined in:
lib/cheffish/rspec/chef_run_support.rb

Defined Under Namespace

Modules: ChefRunSupportInstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RepositorySupport

#when_the_repository

Class Method Details

.extended(klass) ⇒ Object



15
16
17
18
19
# File 'lib/cheffish/rspec/chef_run_support.rb', line 15

def self.extended(klass)
  klass.class_eval do
    include ChefRunSupportInstanceMethods
  end
end

Instance Method Details

#when_the_chef_12_server(*args, **options, &block) ⇒ Object



21
22
23
24
25
# File 'lib/cheffish/rspec/chef_run_support.rb', line 21

def when_the_chef_12_server(*args, **options, &block)
  if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
    when_the_chef_server(*args, :osc_compat => false, :single_org => false, **options, &block)
  end
end

#with_converge(&block) ⇒ Object



39
40
41
42
43
44
# File 'lib/cheffish/rspec/chef_run_support.rb', line 39

def with_converge(&block)
  before :each do
    load_recipe(&block) if block_given?
    converge
  end
end

#with_recipe(&block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cheffish/rspec/chef_run_support.rb', line 27

def with_recipe(&block)
  before :each do
    load_recipe(&block)
  end

  after :each do
    if !chef_client.converge_failed? && !chef_client.converged?
      raise "Never tried to converge!"
    end
  end
end