You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a cookbook that is used on both Linux and Windows platforms. In one of the recipes, that is only called if the cookbook is executed on Windows, we have:
service 'MyService' do
action %i[enable start]
only_if { ::Win32::Service.exists?("MyService") }
not_if { ::File.exist?("#{install_dir}\\scripts\\instance-stopped") }
end
on Windows, rake unit works perfectly. Also, running the cookbook via a converge on either Linux or Windows also works perfectly. However, the rake unit on Linux fails with:
Failures:
myagent::install_windows When set to install agent on Windows converges successfully Failure/Error: expect { chef_run }.to_not raise_error
expected no Exception, got #<NameError: uninitialized constant Win32> with backtrace: # /tmp/chefspec20200924-2530-350e0zfile_cache_path/cookbooks/myagent/resources/install_agent.rb:83:in `block (3 levels) in class_from_file'
I have a cookbook that is used on both Linux and Windows platforms. In one of the recipes, that is only called if the cookbook is executed on Windows, we have:
on Windows, rake unit works perfectly. Also, running the cookbook via a converge on either Linux or Windows also works perfectly. However, the rake unit on Linux fails with:
I have tried adding:
allow(::Win32::Service).to receive(:exists?).with(windows_service[:name]).and_return(true)
to the spec file, but this then causes the rake unit to fail on Windows and Linux.
Is there a way of telling the spec file to only use a line like the allow if we are on Linux?
The text was updated successfully, but these errors were encountered: