module Cheffish::RSpec::ChefRunSupport::ChefRunSupportInstanceMethods

Public Instance Methods

chef_client() click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 77
def chef_client
  @chef_client ||= ChefRun.new(chef_config)
end
chef_config() click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 46
def chef_config
  {}
end
converge(str = nil, file = nil, line = nil, &recipe) click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 71
def converge(str = nil, file = nil, line = nil, &recipe)
  r = recipe(str, file, line, &recipe)
  r.converge
  r
end
expect_converge(str = nil, file = nil, line = nil, &recipe) click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 56
def expect_converge(str = nil, file = nil, line = nil, &recipe)
  expect { converge(str, file, line, &recipe) }
end
expect_recipe(str = nil, file = nil, line = nil, &recipe) click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 50
def expect_recipe(str = nil, file = nil, line = nil, &recipe)
  r = recipe(str, file, line, &recipe)
  r.converge
  expect(r)
end
get(path, *args) click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 39
def get(path, *args)
  if path[0] == "/"
    path = URI.join(rest.url, path)
  end
  rest.get(path, *args)
end
recipe(str = nil, file = nil, line = nil, &recipe) click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 60
def recipe(str = nil, file = nil, line = nil, &recipe)
  unless recipe
    if file && line
      recipe = proc { eval(str, nil, file, line) } # rubocop:disable Security/Eval
    else
      recipe = proc { eval(str) } # rubocop:disable Security/Eval
    end
  end
  RecipeRunWrapper.new(chef_config, &recipe)
end
rest() click to toggle source
# File lib/cheffish/rspec/chef_run_support.rb, line 35
def rest
  ::Chef::ServerAPI.new(Chef::Config.chef_server_url, api_version: "0")
end