我正在编写代码以在Windows服务器上运行资源“ windows_task”。 “首席执行员rspec”抛出错误。
我试图在资源“ windows_task”上运行单元测试,但失败了。是否有任何解决方案或解决方法。我的工作站是一台EC2 Linux服务器,但是尝试测试Windows的资源。
recipes/default.rb
:
windiows_task 'client' do
run_level :highest
command 'ipconfig.exe'
user 'SYSTEM'
frequency :hourly
frequency_modifier 20
end
spec/unit/recipes/default_spec.rb
:
require 'spec_helper'
describe 'windows_test::default' do
context 'when all attributes are default to windows' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
at_exit {ChefSpec::Coverage.report!}
end
实际结果是失败而不是成功:
失败:
1) windows_test::default when all attributes are default to windows converges successfully.
Failure/Error: expect { chef_run }.to_not raise_error
expected no Exception, got #<NameError: uninitialized contstant Chef::Win32::Security
Did you mean? SecurityError> with backtrace:
# /tmpchefspec20190704-../cookbooks.windows_test/recipes/dafault.rb:35:in `from file`
----
----
Finished in 0.73 seconds
1 example, 1 failure