I am trying to get a HelloWorld type example running with ChefSpec. I ran $ chef generate cookbook learn_chef2
to generate a Chef cookbook with the proper directory structure.
I then created a super simple Chef recipe in default.rb:
package 'ant'
package 'php5'
package 'git'
And my ChefSpec test in default_spec.rb:
#require 'spec_helper'
require 'chefspec'
require 'chefspec/berkshelf'
describe 'package::install' do
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
it 'converges successfully' do
expect(chef_run).to install_package('ant')
end
end
However, when I run rspec, I get the following:
/var/lib/gems/2.1.0/gems/rspec-core-3.2.3/lib/rspec/core/formatters/progress_formatter.rb:1:in `<top (required)>': undefined method `require_rspec_core' for RSpec::Support:Module (NoMethodError)
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:1093:in `built_in_formatter'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:573:in `add_formatter'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:589:in `reporter'
from /usr/lib/ruby/vendor_ruby/rspec/core/command_line.rb:25:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:80:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:17:in `block in autorun'
I'm new to Ruby and RSpec, and I'm sure its a simple configuration issue. Any thoughts?
Thanks!