Reputation: 275
I have written a cookbook to download tomcat (cookbook name = 'my_tomcat'). Resource does everything (resource name 'default.rb') and there is no recipe to it. Other cookbooks will call this resource to download the tomcat.
To test this tomcat cookbook, I have written a test cookbook in test/cookbooks/test/recipes/default.rb and added the dependency in berksfile of my cookbook. When I run kitchen test, it gives me below error-
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/test/recipes/default.rb
================================================================================
NoMethodError
-------------
No resource or method named `my_tomcat' for `Chef::Recipe "default"'
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/test/recipes/default.rb:3:in `from_file'
Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/test/recipes/default.rb:
1: package 'java-1.7.0-openjdk'
2:
3>> my_tomcat '/apps/tools/apache' do
4: version '7.0.32'
5: end
6:
Please let me know what I am doing wrong here. Do I need to do some more changes anywhere?
Upvotes: 1
Views: 283
Reputation: 7956
No resource or method
could mean one of a couple things. The very first thing you need to do is make sure that, along with declaring the dependency on your cookbook in the test cookbook's Berksfile
, you also add depends 'cookbook'
to the test cookbook's metadata.rb
file.
Once that's done, if the error persists, the next thing to check is that you're naming your custom resource correctly in the main cookbook.
If doing the first thing doesn't fix the problem, please add the content of your test cookbook's Berksfile
and metadata.rb
to the original question, along with the content of your custom resource file in the main cookbook.
Upvotes: 0
Reputation: 37630
Your cookbook test
has to specify a dependency on your my_tomcat
cookbook, so that its resources are loaded in advance.
Upvotes: 1