ruby - ChefSpec unable to find cookbook -


when run unit test case (written in chefspec) following error:

chef::exceptions::cookbooknotfound: cookbook azuredns not found. if you're loading azuredns cook book, make sure configure dependency in metadata

following spec file, recipe file , metadata file

azuredns/spec/get_azure_token_spec.rb

require 'chefspec' require 'rest-client'  describe 'azuredns::get_azure_token'   let(:chef_run)     # step provider     runner = chefspec::solorunner.new(step_into: ['azuredns_token'])     # read test data json file     file_path = file.expand_path('test_data.json', __dir__)     file = file.open(file_path)     contents = file.read     node_attr = json.parse(contents)     # load test data node object     runner.node.consume_attributes(node_attr)     runner.converge(described_recipe)   end    before(:each)     # mock post method of restclient     allow(restclient).to receive(:post)       .and_return({ access_token: 'i-am-a-token' }.to_json)   end    'retrieves token'     expect(chef_run).to retrieve_azuredns_token('azure_token')   end    'varifies expected value of azure_rest_token'     expect(chef_run.node['azure_rest_token']).to eq('bearer i-am-a-token')   end    'does not retrieve token due incorrect resource name'     expect(chef_run).to_not retrieve_azuredns_token('azure_token1')   end    'raises exception due error in response'     # mock post method of restclient     allow(restclient).to receive(:post)       .and_return({ error: 'invalid_grant' }.to_json)     expect { chef_run }.to raise_error(exception)   end end 

azuredns/recipe/get_azure_token.rb

require 'rest_client' require 'json'  cloud_name = node['workorder']['cloud']['ciname'] cloud = node['workorder']['services']['dns'][cloud_name] dns_attributes = cloud['ciattributes']  #  establish connection , security token token = azuredns_token 'azure_token'   tenant_id dns_attributes['tenant_id']   client_id dns_attributes['client_id']   client_secret dns_attributes['client_secret'] end  token.run_action(:retrieve) 

azuredns/metadata.rb

name             'azuredns' maintainer       'shaffan' maintainer_email 'shaffan.chaudhry1@gmail.com' license          'apache license, version 2.0' description      'installs/configures azure dns' version          '0.1.0' depends          'azure' 

please help!

azuredns != azuredns :-)

fix name in metadata. chef, , pretty unix world, case sensitive.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -