[chef] Re: Re: ChefDK and rake


Chronological Thread 
  • From: Booker Bense < >
  • To:
  • Subject: [chef] Re: Re: ChefDK and rake
  • Date: Fri, 15 Aug 2014 09:58:24 -0700




On Fri, Aug 15, 2014 at 9:44 AM, Daniel DeLeo < " target="_blank"> > wrote:
On Friday, August 15, 2014 at 9:39 AM, Booker Bense wrote:
> I'm testing a cookbook I set up with mis using the ChefDK environment.
>
> I have done chef shell-init and

Just checking, you did eval "$(chef shell-init bash)” ?

>
> which rspec returns
>
> /opt/chefdk/embedded/bin/rspec
>
> This command runs the chefspec tests.
>
> chef exec rspec test/unit/spec
You don’t need `chef exec` if you configure your shell via shell-init

Yes, rspec test/unit/spec on the command line works as well. So the shell-init part is correct.

I did the obvious after a little googling and added this to the rake file 

require 'rspec/core/rake_task'
desc 'Run ChefSpec unit tests'
RSpec::Core::RakeTask.new(:spec) do |t, _args|
  t.rspec_opts = 'test/unit/spec'
  t.rspec_path = '/opt/chefdk/embedded/bin/rspec'
end

And now I get this error, which seems pretty odd. This is the error I was originally getting, I thought it meant I was
running a different rspec, but apparently not. 

rake spec
/opt/chefdk/embedded/bin/ruby -S /opt/chefdk/embedded/bin/rspec test/unit/spec
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-expectations-2.99.2/lib/rspec/matchers/built_in/raise_error.rb:5:in `<class:RaiseError>': uninitialized constant RSpec::Matchers::BuiltIn::RaiseError::MatchAliases (NameError)
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-expectations-2.99.2/lib/rspec/matchers/built_in/raise_error.rb:4:in `<module:BuiltIn>'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-expectations-2.99.2/lib/rspec/matchers/built_in/raise_error.rb:3:in `<module:Matchers>'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-expectations-2.99.2/lib/rspec/matchers/built_in/raise_error.rb:2:in `<module:RSpec>'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-expectations-2.99.2/lib/rspec/matchers/built_in/raise_error.rb:1:in `<top (required)>'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chefspec-3.4.0/lib/chefspec/expect_exception.rb:1:in `require'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chefspec-3.4.0/lib/chefspec/expect_exception.rb:1:in `<top (required)>'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chefspec-3.4.0/lib/chefspec.rb:26:in `require_relative'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chefspec-3.4.0/lib/chefspec.rb:26:in `<top (required)>'
from /Users/booker/work/sysman/slac_motd/test/unit/spec/spec_helper.rb:2:in `require'
from /Users/booker/work/sysman/slac_motd/test/unit/spec/spec_helper.rb:2:in `<top (required)>'
from /Users/booker/work/sysman/slac_motd/test/unit/spec/default_spec.rb:3:in `require_relative'
from /Users/booker/work/sysman/slac_motd/test/unit/spec/default_spec.rb:3:in `<top (required)>'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `load'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `block in load_spec_files'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `each'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `load_spec_files'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/command_line.rb:18:in `run'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:103:in `run'
from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:17:in `block in autorun

- Booker C. Bense



Archive powered by MHonArc 2.6.16.

§