Hi All,
I was running a simple unit test in my laptop ( Windows professional 7), but encountered an issue while running for a simple scenario on checking include recipe ( attached the cookbook) . Please help me to understand the error, I am unable to proceed further to test the example you have shown during you training session.
Any suggestion to proceed further will help me to learn chef-spec.
Regards,
Prem
default.rb
include_recipe ‘httpd::install’
default_spec.rb:
Cookbook Name:: httpd
Spec:: default
Copyright © 2018 The Authors, All Rights Reserved.
require ‘spec_helper’
describe ‘httpd::default’ do
context ‘When all attributes are default, on an unspecified platform’ do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it 'it includes the install recipe' do
expect(chef_run).to include_recipe('httpd::install')
end
end
end
package node[‘package’][‘httpd’]
Error details:
cookbooks\httpd>chef exec rspec spec\unit\recipes\default_spec.rb
FF
Failures:
-
httpd::default When all attributes are default, on an unspecified platform converges successfully
Failure/Error: expect { chef_run }.to_not raise_errorexpected no Exception, got #<Net::HTTPFatalError: 502 “cannotconnect”> with backtrace:
# ./spec/unit/recipes/default_spec.rb:13:inblock (3 levels) in <top (required)>' # ./spec/unit/recipes/default_spec.rb:17:in
block (4 levels) in <top (required)>’
# ./spec/unit/recipes/default_spec.rb:17:in `block (3 levels) in <top (required)>’./spec/unit/recipes/default_spec.rb:17:in `block (3 levels) in <top (required)>’
-
httpd::default When all attributes are default, on an unspecified platform it includes the install123 recipe
Failure/Error: runner.converge(described_recipe)Net::HTTPFatalError:
502 “cannotconnect”./spec/unit/recipes/default_spec.rb:13:in `block (3 levels) in <top (required)>’
./spec/unit/recipes/default_spec.rb:21:in `block (3 levels) in <top (required)>’
Finished in 6.62 seconds (files took 53.3 seconds to load)
2 examples, 2 failures
Failed examples:
rspec ./spec/unit/recipes/default_spec.rb:16 # httpd::default When all attributes are default, on an unspecified platform converges successfully
rspec ./spec/unit/recipes/default_spec.rb:20 # httpd::default When all attributes are default, on an unspecified platform it includes the install123 recipe