Created
August 8, 2014 21:22
-
-
Save vinyar/c6a4a1b3fc631634a179 to your computer and use it in GitHub Desktop.
serverspec failing on reg_key numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)>' |
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) "
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
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
Failure/Error: it { should have_property_value('ACSettingIndex', :type_dword, '1200'.to_i(16))}
NoMethodError: undefined method `rjust' for 4608:Fixnum
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