chef - Chefspec with Hashicorp Vault -


i'm trying use chefspec test implementation of chef , hashicorp vault

recipe

chef_gem 'vault'   compile_time true if chef::resource::chefgem.instance_methods(false).include?(:compile_time) end  require 'vault'  vault.address = 'https://address:8200' vault.token = citadel['foo/bar'] vault.auth_token.renew_self 

test

require_relative '../spec_helper'  describe 'wrapper::default'   context 'role foo'     let(:chef_run)       chefspec::solorunner.new(platform: 'ubuntu', version: '14.04') |node|         node.default['role'] = 'foo'         const_set(:vault, module.new)       end.converge(described_recipe)     end      before(:each)       allow_any_instance_of(chef::recipe).to receive(:require).and_call_original       allow_any_instance_of(chef::recipe).to receive(:require).with('vault').and_return(true)       allow_any_instance_of(::vault).to receive(:address).and_call_original       allow_any_instance_of(::vault).to receive(:address).with('https://localhost:8200').and_return(true)     end      'install vault gem'       expect(chef_run).to install_chef_gem('vault')     end   end end 

error

failure/error: expect(chef::recipe::vault).to receive(:address).and_call_original       nameerror:        uninitialized constant vault 

how stub vault variables? hashicorp vault, not chef-vault.

i responded email already, want allow_any_instance_of(::vault) , similar, , may have create module (const_set(:vault, module.new)) if doesn't exist already.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -