0

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!

joeglin2000
  • 85
  • 2
  • 6

1 Answers1

0

Normally what you have to do is require 'rspec' as the first line but I'm pretty sure that's written in the spec_helper.rb which you have commented out on line 1.

Konstantin Rudy
  • 2,237
  • 25
  • 22
  • The two uncommented `require` lines are from the generated spec_helper file. During troubleshooting I thought I'd eliminate the spec_helper file and put its two lines in my RSpec file. I added `require 'rspec'` per your suggestion but got the same result. – joeglin2000 May 12 '15 at 20:52