Skip to content

Instantly share code, notes, and snippets.

@nicgrayson
Last active December 17, 2015 16:29
Show Gist options
  • Save nicgrayson/5639068 to your computer and use it in GitHub Desktop.
Save nicgrayson/5639068 to your computer and use it in GitHub Desktop.
Trying to include a recipe that includes ohai::default
include_recipe "ohai"
require 'spec_helper'
describe 'ohai example' do
let(:chef_run) do
runner = converge_chef_run
end
runner.converge 'ohai'
end
it "should include ohai and not break" do
expect(chef_run).to include_recipe 'ohai'
end
end
be rspec spec/ohai_spec.rb
================================================================================
Recipe Compile Error in /var/folders/98/my9tl6c977dcn_kj67bx19100000gp/T/chefspec-berks20130523-91327-17za2te/ohai/recipes/default.rb
================================================================================
TypeError
---------
can't convert nil into String
Cookbook Trace:
---------------
/var/folders/98/my9tl6c977dcn_kj67bx19100000gp/T/chefspec-berks20130523-91327-17za2te/ohai/recipes/default.rb:51:in `read'
/var/folders/98/my9tl6c977dcn_kj67bx19100000gp/T/chefspec-berks20130523-91327-17za2te/ohai/recipes/default.rb:51:in `from_file'
Relevant File Content:
----------------------
/var/folders/98/my9tl6c977dcn_kj67bx19100000gp/T/chefspec-berks20130523-91327-17za2te/ohai/recipes/default.rb:
44: resource = ohai 'custom_plugins' do
45: action :nothing
46: end
47:
48: # only reload ohai if new plugins were dropped off OR
49: # node['ohai']['plugin_path'] does not exists in client.rb
50: if reload_ohai ||
51>> !(::IO.read(Chef::Config[:config_file]) =~ /Ohai::Config\[:plugin_path\]\s*<<\s*["']#{node['ohai']['plugin_path']}["']/)
52:
53: resource.run_action(:reload)
54: end
55:
F
Failures:
1) ohai example should include ohai and not break
Failure/Error: runner.converge 'ohai'
TypeError:
can't convert nil into String
# /var/folders/98/my9tl6c977dcn_kj67bx19100000gp/T/chefspec-berks20130523-91327-17za2te/ohai/recipes/default.rb:51:in `read'
# /var/folders/98/my9tl6c977dcn_kj67bx19100000gp/T/chefspec-berks20130523-91327-17za2te/ohai/recipes/default.rb:51:in `from_file'
# ./spec/ohai_spec.rb:6:in `block (2 levels) in <top (required)>'
# ./spec/ohai_spec.rb:9:in `block (2 levels) in <top (required)>'
Finished in 0.03731 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/ohai_spec.rb:8 # ohai example should include ohai and not break
require 'chefspec'
require 'berkshelf'
require 'tmpdir'
require 'fileutils'
TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$: << File.expand_path(File.dirname(__FILE__))
Berkshelf.ui.mute!
berks = Berkshelf::Berksfile.from_file(File.join(TOPDIR, "Berksfile"))
tmpdirname = Dir.mktmpdir("chefspec-berks")
berks.install(path: tmpdirname, only: "external")
COOKBOOK_PATH = tmpdirname
RSpec.configure do |c|
c.after(:all) do
FileUtils.rm_rf(tmpdirname)
end
end
def converge_chef_run()
ChefSpec::ChefRunner.new(cookbook_path: COOKBOOK_PATH, platform: 'ubuntu', version: '12.04', log_levl: :debug) do |node|
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment