Я застрял в тесте chefspec, который входит в мой lwrp ниже и утверждает, что он создает каталог.Назначение new_resource в тесте chefspec
describe 'mw-tomcat::chefspec' do
let(:chef) do
ChefSpec::SoloRunner.new(step_into: ['mw_tomcat_tree']) do |node|
node.set['mw']['domain'] = domain
node.set['mw']['gemrepo'] = gemrepo
end
end
let(:chef_run) { chef.converge(described_recipe) }
it 'creates the catalina_base directory' do
expect(chef_run).to create_directory('/apps/bweb/apps/instance1')
end
done
Тест работает, если я раскомментировать строку ниже, но терпит неудачу при попытке получить значение из new_resource.settings
action :create do
settings = new_resource.settings
catalina_base=settings['catalina_base']
#catalina_base='/apps/bweb/apps/instance1'
directory "#{catalina_base}" do
mode 0755
owner settings['user']
group settings['group']
recursive true
action :create
end
end
Есть ли способ в chefspec передать в значении new_resource выше?
Спасибо за любую помощь.
Эдвард
* Обновление
Он выдает следующее сообщение:
[2015-08-21T19:25:02+01:00] DEBUG: resources for generic directory resource enabled on node include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources that survived replacement include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources for generic directory resource enabled on node include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources that survived replacement include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources for generic directory resource enabled on node include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources that survived replacement include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources for generic directory resource enabled on node include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources that survived replacement include: [Chef::Resource::Directory]
[2015-08-21T19:25:02+01:00] DEBUG: resources for generic link resource enabled on node include: [Chef::Resource::Link]
[2015-08-21T19:25:02+01:00] DEBUG: resources that survived replacement include: [Chef::Resource::Link]
[2015-08-21T19:25:02+01:00] DEBUG: resources for generic link resource enabled on node include: [Chef::Resource::Link]
[2015-08-21T19:25:02+01:00] DEBUG: resources that survived replacement include: [Chef::Resource::Link]
[2015-08-21T19:25:02+01:00] INFO: Processing directory[] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 51)
[2015-08-21T19:25:02+01:00] INFO: Processing directory[/bin] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 77)
[2015-08-21T19:25:02+01:00] INFO: Processing directory[/conf] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 77)
[2015-08-21T19:25:02+01:00] INFO: Processing directory[/lib] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 77)
[2015-08-21T19:25:02+01:00] INFO: Processing directory[/logs] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 77)
[2015-08-21T19:25:02+01:00] INFO: Processing directory[/temp] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 77)
[2015-08-21T19:25:02+01:00] INFO: Processing directory[/webapps] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 77)
[2015-08-21T19:25:02+01:00] INFO: Processing directory[/work] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 77)
[2015-08-21T19:25:02+01:00] INFO: Processing link[/lib/BESTFilter] action create (/home/we_edqui/mw-chef-repo/cookbooks/mw-tomcat/providers/tree.rb line 109)
creates the catalina_base directory (FAILED - 1)
Failures:
1) mw-tomcat::chefspec creates the catalina_base directory
Failure/Error: expect(chef_run).to create_directory('/apps/bweb/apps/instance1')
expected "directory[/apps/bweb/apps/instance1]" with action :create to be in Chef run. Other directory resources:
directory[]
directory[/bin]
directory[/conf]
directory[/lib]
directory[/logs]
directory[/temp]
directory[/webapps]
directory[/work]
# ./spec/default_spec.rb:68:in `block (2 levels) in <top (required)>'
Finished in 0.80061 seconds (files took 4.72 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/default_spec.rb:67 # mw-tomcat::chefspec creates the catalina_base directory
Полный выход находится на http://fpaste.org/257744/14401829/
Можете ли вы дать нам больше, чем «не удалось»? Какова была ошибка, добавление сообщения об ошибке было бы еще лучше. –
Да, конечно! Я обновлю сообщение. – Edward