-
-
Save vinyar/c6a4a1b3fc631634a179 to your computer and use it in GitHub Desktop.
Windows registry key "HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E" should have property value "ACSettingIndex", :type_dword, "1200" | |
Failure/Error: it { should have_property_value('ACSettingIndex', :type_dword, '1200')} | |
$exitCode = 1 | |
$ProgressPreference = "SilentlyContinue" | |
try { | |
$success = ((Compare-Object (Get-Item 'Registry::HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E').GetValue('ACSettingIndex') 4608) -eq $null) | |
if ($success -is [Boolean] -and $success) { $exitCode = 0 } | |
} catch { | |
Write-Output $_.Exception.Message | |
} | |
Write-Output "Exiting with code: $exitCode" | |
exit $exitCode | |
Exiting with code: 1 | |
expected #has_property_value?("ACSettingIndex", :type_dword, "1200") to return true, got false | |
# ./test/integration/windows/spec/localhost/2012_spec.rb:144:in `block (2 levels) in <top (required)>' |
Seems I cant really hack around it either:
Hack:
describe windows_registry_key('HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E') do
it { should exist }
it { should have_property_value('DCSettingIndex', :type_dword, "#{"1200".to_i(16)}")}
it { should have_property_value('ACSettingIndex', :type_dword, '1200'.to_i(16))}
end
Error:
- Windows registry key "HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E" should have property value "DCSettingIndex", :type_dword, "4608"
Failure/Error: it { should have_property_value('DCSettingIndex', :type_dword, "#{"1200".to_i(16)}")}
$exitCode = 1
$ProgressPreference = "SilentlyContinue"
try {
$success = ((Compare-Object (Get-Item 'Registry::HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E').GetValue('DCSettingIndex') 17928) -eq $null)
if ($success -is [Boolean] -and $success) { $exitCode = 0 }
} catch {
Write-Output $_.Exception.Message
}
Write-Output "Exiting with code: $exitCode"
exit $exitCode
Exiting with code: 1
expected #has_property_value?("DCSettingIndex", :type_dword, "4608") to return true, got false
# ./test/integration/windows/spec/localhost/2012_spec.rb:143:in `block (2 levels) in <top (required)>'
- Windows registry key "HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E" should have property value "ACSettingIndex", :type_dword, 4608
Failure/Error: it { should have_property_value('ACSettingIndex', :type_dword, '1200'.to_i(16))}
NoMethodError: undefined method `rjust' for 4608:Fixnum
undefined method `rjust' for 4608:Fixnum
# ./test/integration/windows/spec/localhost/2012_spec.rb:144:in `block (2 levels) in <top (required)>'
Finished in 1.09 seconds
3 examples, 2 failures
Failed examples:
rspec ./test/integration/windows/spec/localhost/2012_spec.rb:143 # Windows registry key "HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E" should have property value "DCSettingIndex", :type_dword, "4608"
rspec ./test/integration/windows/spec/localhost/2012_spec.rb:144 # Windows registry key "HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E" should have property value "ACSettingIndex", :type_dword, 4608
I didnt find any elegant way of hacking it, so until serverspec is fixed, I converted all of the actual values to what serverspec expects them to be with " .to_s(16) "
actual test:
describe windows_registry_key('HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E') do
it { should have_property_value('DCSettingIndex', :type_dword, '1200')}
it { should have_property_value('ACSettingIndex', :type_dword, '1200')}
end
Notice in the output above, that the test compares 1200 to 4608 --> .GetValue('ACSettingIndex') 4608)
Some messing around later in ruby land - "1200".to_i(16) = 4608