I am trying to run chefspec tests for cookbook Nginx
and it is in the same directory as a bunch of others like bar
. For my InSpec tests run kitchen test
in ../../Nginx
which has my .kitchen.yml
file.
Reason I mention the bar
cookbook is that it is the first one in the run list in my .kitchen.yml
. I run bar
and then it calls on a few others too as well as Nginx is further along in the cookbook.
Hope that made some sense.
Here is my error message in the terminal
[2018-05-15T12:45:57-04:00] WARN: Port 8889 not available
nginx::default
Nginx
Converges successfully (FAILED - 1)
Failures:
1) nginx::default Nginx Converges successfully
Failure/Error: expect { chef_run }.to_not raise_error
expected no Exception, got #<NoMethodError: undefined method `[]' for nil:NilClass> with backtrace:
# /var/folders/pj/c4gpnwws6n7gb7x_plpv9hzc0000gp/T/chefspec20180515-32598-1um8wa6file_cache_path/cookbooks/nginx/recipes/_configure.rb:23:in `from_file'
# /var/folders/pj/c4gpnwws6n7gb7x_plpv9hzc0000gp/T/chefspec20180515-32598-1um8wa6file_cache_path/cookbooks/nginx/recipes/default.rb:324:in `from_file'
# ./spec/unit/recipes/default_spec.rb:10:in `block (3 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:13:in `block (4 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:13:in `block (3 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:13:in `block (3 levels) in <top (required)>'
Finished in 4.08 seconds (files took 1.98 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/unit/recipes/default_spec.rb:12 # nginx::default Nginx Converges successfully
My command I am using
Josh:nginx josh$ chef exec rspec spec/unit/recipes/default_spec.rb --format d
My test file
Super basic just till it runs then I can use my full test list.
require 'chefspec'
describe 'nginx::default' do
context 'Nginx' do
let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
it 'Converges successfully' do
expect { chef_run }.to_not raise_error
end
end #end context Nginx
end # end describe nginx::default