Hi
I am having this ChefSpec test, specifically just the piece of code. I tried to change the node attribute in this context block (especially in 'it' block). It was working fine and passed on my server when I ran the test, but whenever I ran the test in Azure DevOps chef pipeline, it failed because the node attribute did not get changed at all. I have checked the ChefDk and ChefSpec version of both my machine and in the Azure DevOps build agent, they are both the same.
This is my ChefSpec code:
#cookbooks/myCookbook/spec/my_spec.rb
#some code here
describe 'myOrg::windows_service' do
let(:chef_run) do
ChefSpec::SoloRunner.new do |node|
node.default['windows_services'] = windows_services
node.default['base_deployment_path'] = base_deployment_path
node.default['service_account_prefixes'] = service_account_prefixes
end.converge(described_recipe)
end
#some code here
#this is where things start going wrong and inconsistent
#in between running on server and on Azure DevOps pipeline.
# When I ran this chefSpec test on my server, this code DID
#actually change the node attribute as below, but when in Azure
#DevOps pipeline, it DIDN'T work at all and stayed the same
#as default. Not sure why it behaved like this ?
context 'Is dev machine' do
it "configures a '#{windows_service[:name]}' with an explicit action" do
chef_run.node.normal['is_dev_machine'] = true
chef_run.converge(described_recipe)
executable_location = "#{base_deployment_path}/#{windows_service[:dev_path]}"
expect(chef_run).to configure_windows_service(windows_service[:name]).with(
sensitive: true,
startup_type: mapped_startup_types[windows_service[:startup_type]],
delayed_start: false,
binary_path_name: executable_location,
run_as_user: full_service_account_name,
run_as_password: service_account_password,
description: windows_service[:description]
)
end
end
end
Could anyone help me to point out what have I missed out? Thanks so much