Re: chef version with chef exec rspec

Thanks for the feedback - glad to know I am doing something right :slight_smile:

I agree, it would be nice if chef could automatically do a bundle exec when
there is a Gemfile.


On Thu Jan 29 2015 at 5:16:40 PM Lamont Granquist wrote:

I think you've done the correct thing to pin the version of chef used to
run chefspec against your cookbooks to the same version in your prod

It'd probably be nice if chef exec automatically could do a bundle exec
if it detected a Gemfile, similarly to rubygems-bundler:
RVM: Ruby Version Manager - Bundler Integration with RVM or rbenv-bundler:
GitHub - carsomyr/rbenv-bundler: an rbenv plugin that makes shims aware of bundle installation paths

On 1/29/15 1:00 PM, Ben Roling wrote:

I'm just finally trying out ChefDK for the first time and when running
unit tests on one of my cookbooks I notice warnings like the following:

.[2015-01-29T14:47:55-06:00] WARN: The on_platforms option to node_map
has been deprecated

When I tracked this message down to coming from 'node_map.rb' in the
chef gem, I noticed it was from Chef 12.

That got me to thinking -- how am I supposed to define the Chef
version I want my unit tests to run against? I just assumed they
would run against the Chef version dictated by the ChefDK version I
was using (0.3.4 in this case to target Chef 11.16.4).

And more generally, how exactly am I supposed to run the tests?

At first I simply ran 'chef exec rspec' (or chef shell-init and then
just 'rspec').

I guess first question is, is that how I am supposed to run them?

I was able to control the Chef version by specifying it in my Gemfile
and running 'chef exec bundle update' and 'chef exec bundle exec
rspec', but I'm not sure I am really supposed to be doing that?

Any guidance would be appreciated!