Skip to content

Commit 715618b

Browse files
committed
Fix PSObject serialization, tests
1 parent e482fdd commit 715618b

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

Source/Metadata.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ function ConvertTo-Metadata {
220220
}) -f ($(
221221
ForEach($key in $InputObject | Get-Member -MemberType Properties | Select-Object -ExpandProperty Name) {
222222
if("$key" -match '^(\w+|-?\d+\.?\d*)$') {
223-
"$key = " + (ConvertTo-Metadata $InputObject[$key] -AsHashtable:$AsHashtable)
223+
"$key = " + (ConvertTo-Metadata $InputObject.$key -AsHashtable:$AsHashtable)
224224
}
225225
else {
226-
"'$key' = " + (ConvertTo-Metadata $InputObject[$key] -AsHashtable:$AsHashtable)
226+
"'$key' = " + (ConvertTo-Metadata $InputObject.$key -AsHashtable:$AsHashtable)
227227
}
228228
}
229229
) -split "`n" -join "`n$t")

Specs/Configuration.Steps.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,11 @@ When "the settings file should (\w+)\s*(.*)?" {
321321
param($operator, $data)
322322
# Normalize line endings, because the module does:
323323
$data = [regex]::escape(($data -replace "\r?\n","`n")) -replace '\\n','\r?\n'
324-
if($operator -eq "Contain"){ $operator = "ContainMultiline"}
325-
${SettingsFile} | Should $operator $data
324+
if($operator -eq "Contain"){
325+
(Get-Content ${SettingsFile} -raw) -match $data | Should Be $True
326+
} else {
327+
${SettingsFile} | Should $operator $data
328+
}
326329
}
327330

328331
Given "the settings file does not exist" {
@@ -351,6 +354,9 @@ When "we expect an? (?<type>warning|error|verbose) in the (?<module>.*) module"
351354
}
352355
}
353356

357+
# Then the error is logged exactly 2 times
358+
# Then the warning is logged 3 times
359+
# Then the error is logged
354360
# this step lets us verify the number of calls to those three mocks
355361
When "the (?<type>warning|error|verbose) is logged(?: (?<exactly>exactly) (\d+) times?)?" {
356362
param($count, $exactly, $type)
@@ -381,8 +387,6 @@ When "we add a converter with a number as a key" {
381387
}
382388
}
383389

384-
# Then the error is logged exactly 2 times
385-
386390
Then "the settings object should be of type (.*)" {
387391
param([Type]$Type)
388392
$Settings | Should BeOfType $Type

0 commit comments

Comments
 (0)