Chef spec error: expected "execute[..]" with action :run to be in Chef run. Other execute resources:
Chef spec error: expected "execute[..]" with action :run to be in Chef run. Other execute resources:
我收到标题中所示的 chefspec 错误。以下是我遇到错误的配方资源和规格:
资源:
execute 'generate ssl cert for simple https file server' do
cwd '/root/git/chef-bluecloud/bin/'
command <<-EOH
openssl req -new -days 365 -nodes -x509 \
-subj "/C=US/ST=NY/L=Somers/O=IBM/CN=bluecloud.xyz.com" \
-keyout localhost.pem \
-out localhost.pem
EOH
not_if 'test -f localhost.pem' # TODO: use ruby code instead of bash ::File.exists(...)
end
规格:
it 'checks ssl cert generation for simple https file server' do
expect(chef_run).to run_execute('openssl req -new -days 365 -nodes -x509 \
-subj "/C=US/ST=NY/L=Somers/O=IBM/CN=bluecloud.xyz.com" \
-keyout localhost.pem \
-out localhost.pem \
').with(cwd:'/root/git/chef-bluecloud/bin/')
expect(chef_run).to_not run_execute('openssl null').with(cwd:'/root/git/chef-bluecloud/bin/')
end
关于如何解决它的任何想法?
谢谢!
您为 ChefSpec 资源匹配器提供的值是资源的名称,在本例中为 'generate ssl cert for simple https file server'
。所以你的匹配器应该看起来像 run_execute('generate ssl cert for simple https file server').with(command: 'openssl etc etc')
.
我不确定你对第二个期望的目标是什么。
我收到标题中所示的 chefspec 错误。以下是我遇到错误的配方资源和规格:
资源:
execute 'generate ssl cert for simple https file server' do
cwd '/root/git/chef-bluecloud/bin/'
command <<-EOH
openssl req -new -days 365 -nodes -x509 \
-subj "/C=US/ST=NY/L=Somers/O=IBM/CN=bluecloud.xyz.com" \
-keyout localhost.pem \
-out localhost.pem
EOH
not_if 'test -f localhost.pem' # TODO: use ruby code instead of bash ::File.exists(...)
end
规格:
it 'checks ssl cert generation for simple https file server' do
expect(chef_run).to run_execute('openssl req -new -days 365 -nodes -x509 \
-subj "/C=US/ST=NY/L=Somers/O=IBM/CN=bluecloud.xyz.com" \
-keyout localhost.pem \
-out localhost.pem \
').with(cwd:'/root/git/chef-bluecloud/bin/')
expect(chef_run).to_not run_execute('openssl null').with(cwd:'/root/git/chef-bluecloud/bin/')
end
关于如何解决它的任何想法? 谢谢!
您为 ChefSpec 资源匹配器提供的值是资源的名称,在本例中为 'generate ssl cert for simple https file server'
。所以你的匹配器应该看起来像 run_execute('generate ssl cert for simple https file server').with(command: 'openssl etc etc')
.
我不确定你对第二个期望的目标是什么。