chef / chef-vault-testfixtures

provides an RSpec shared context for testing Chef cookbooks that use chef-vault
Apache License 2.0
7 stars 10 forks source link

ChefDK support #14

Closed jmccann closed 8 years ago

jmccann commented 8 years ago

I was curious if there is a trick to getting this to work with ChefDK. I'm running into conflicts with Hashie:

$ chef --version
Chef Development Kit Version: 0.9.0
chef-client version: 12.5.1
berks version: 4.0.1
kitchen version: 1.4.2
$ gem install chef-vault-testfixtures
Fetching: chef-vault-testfixtures-0.5.0.gem (100%)
Successfully installed chef-vault-testfixtures-0.5.0
1 gem installed
$ rspec
/opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:2112:in `raise_if_conflicts': Unable to activate chef-vault-testfixtures-0.5.0, because hashie-3.4.2 conflicts with hashie (~> 2.1) (Gem::ConflictError)
    from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1280:in `activate'
    from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:198:in `rescue in try_activate'
    from /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:195:in `try_activate'
...

I realize I could maintain a Gemfile then bundle install and bundle exec to address this but have noticed a trend of using ChefDK to avoid having to maintain gem dependencies and was wondering if there was a way to have it work here.

If not are there plans have this work 'natively' with ChefDK, which to me would mean having the gem work using the core gems included in ChefDK (as in Hashie 3.4.2 which is included in ChefDK 0.9.0 to address the issue above)?

Or maybe it'd be better to ask the maintainers of ChefDK if they could pull in this additional gem into their product?

Thanks!

philoserf commented 8 years ago

@jmccann Have you tried installing into the chefdk gem space?

chef gem install chef-vault-testfixtures

jf647 commented 8 years ago

Typically chef-vault-testfixtures installs via bundler and a Gemfile, which keeps its dependencies isolated. Mark is correct that if you haven't run chef shell-init bash prior to running gem install ... then you might be trying to install into some other ruby install, but we use it all the time with bundler.

The idea is that if I create a cookbook that uses vault and -testfixtures, and six months later ChefDK has been upgraded, or ChefSpec or Test-Kitchen have been released with new features, you can grab my cookbook from source control, set up dependencies with bundler and be ensured of getting the same results I did no matter how long it's been since I last ran tests.

jmccann commented 8 years ago

Yes, I have my env set to use ChefDK ENV by default. I also tried with gem install and chef gem install to make sure.

I'll continue to use Gemfiles in the case where I need to use this gem then. Was just wondering if I was missing something obvious.

Thanks for the responses and the gem! :smile: