1

I am getting chefspec error as shown in title. Below are recipe resource and spec for which I am getting error:

Resource:

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

Spec:

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

Any ideas on how to resolve it ? Thanks !

4

1 回答 1

2

您为 ChefSpec 资源匹配器提供的值是资源的名称,在本例中为'generate ssl cert for simple https file server'. 所以你的匹配器应该看起来像run_execute('generate ssl cert for simple https file server').with(command: 'openssl etc etc').

我不确定您对第二个期望的目标是什么。

于 2015-11-19T06:53:49.263 回答