diff --git a/test/Scoop-Alias.Tests.ps1 b/test/Scoop-Alias.Tests.ps1 index 028309d32..a29cdf0b7 100644 --- a/test/Scoop-Alias.Tests.ps1 +++ b/test/Scoop-Alias.Tests.ps1 @@ -13,10 +13,10 @@ describe "add_alias" -Tag 'Scoop' { context "alias doesn't exist" { it "creates a new alias" { $alias_file = "$shimdir\scoop-rm.ps1" - $alias_file | should not exist + $alias_file | should -not -exist add_alias "rm" '"hello, world!"' - Invoke-Expression $alias_file | should be "hello, world!" + Invoke-Expression $alias_file | should -be "hello, world!" } } @@ -24,10 +24,10 @@ describe "add_alias" -Tag 'Scoop' { it "does not change existing alias" { $alias_file = "$shimdir\scoop-rm.ps1" new-item $alias_file -type file - $alias_file | should exist + $alias_file | should -exist add_alias "rm" "test" - $alias_file | should FileContentMatch "" + $alias_file | should -FileContentMatch "" } } } @@ -45,11 +45,11 @@ describe "rm_alias" { $alias_file = "$shimdir\scoop-rm.ps1" add_alias "rm" '"hello, world!"' - $alias_file | should exist + $alias_file | should -exist mock get_config { @(@{"rm" = "scoop-rm"}) } rm_alias "rm" - $alias_file | should not exist + $alias_file | should -not -exist } } } diff --git a/test/Scoop-Config.Tests.ps1 b/test/Scoop-Config.Tests.ps1 index 0e043d614..086b18968 100644 --- a/test/Scoop-Config.Tests.ps1 +++ b/test/Scoop-Config.Tests.ps1 @@ -8,13 +8,13 @@ describe "hashtable" -Tag 'Scoop' { $obj = convertfrom-json $json $ht = hashtable $obj - $ht.one | should beexactly 1 - $ht.two[0].a | should be "a" - $ht.two[1] | should be "b" - $ht.two[2] | should beexactly 2 - $ht.three.four | should beexactly 4 - $ht.five | should beexactly $true - $ht.six | should beexactly $false - [System.DateTime]::Equals($ht.seven, $(New-Object System.DateTime (2018, 06, 25, 09, 03, 15, 805))) | should be $true + $ht.one | should -beexactly 1 + $ht.two[0].a | should -be "a" + $ht.two[1] | should -be "b" + $ht.two[2] | should -beexactly 2 + $ht.three.four | should -beexactly 4 + $ht.five | should -beexactly $true + $ht.six | should -beexactly $false + [System.DateTime]::Equals($ht.seven, $(New-Object System.DateTime (2018, 06, 25, 09, 03, 15, 805))) | should -betrue } } diff --git a/test/Scoop-GetOpts.Tests.ps1 b/test/Scoop-GetOpts.Tests.ps1 index 7796defbe..21fe49961 100644 --- a/test/Scoop-GetOpts.Tests.ps1 +++ b/test/Scoop-GetOpts.Tests.ps1 @@ -4,68 +4,68 @@ describe "getopt" -Tag 'Scoop' { it 'handle short option with required argument missing' { $null, $null, $err = getopt '-x' 'x:' '' - $err | should be 'Option -x requires an argument.' + $err | should -be 'Option -x requires an argument.' $null, $null, $err = getopt '-xy' 'x:y' '' - $err | should be 'Option -x requires an argument.' + $err | should -be 'Option -x requires an argument.' } it 'handle long option with required argument missing' { $null, $null, $err = getopt '--arb' '' 'arb=' - $err | should be 'Option --arb requires an argument.' + $err | should -be 'Option --arb requires an argument.' } it 'handle unrecognized short option' { $null, $null, $err = getopt '-az' 'a' '' - $err | should be 'Option -z not recognized.' + $err | should -be 'Option -z not recognized.' } it 'handle unrecognized long option' { $null, $null, $err = getopt '--non-exist' '' '' - $err | should be 'Option --non-exist not recognized.' + $err | should -be 'Option --non-exist not recognized.' $null, $null, $err = getopt '--global','--another' 'abc:de:' 'global','one' - $err | should be 'Option --another not recognized.' + $err | should -be 'Option --another not recognized.' } it 'remaining args returned' { $opt, $rem, $err = getopt '-g','rem' 'g' '' - $err | should be $null - $opt.g | should be $true - $rem | should not be $null - $rem.length | should be 1 - $rem[0] | should be 'rem' + $err | should -benullorempty + $opt.g | should -betrue + $rem | should -not -benullorempty + $rem.length | should -be 1 + $rem[0] | should -be 'rem' } it 'get a long flag and a short option with argument' { $a = "--global -a 32bit test" -split ' ' $opt, $rem, $err = getopt $a 'ga:' 'global','arch=' - $err | should be $null - $opt.global | should be $true - $opt.a | should be '32bit' + $err | should -benullorempty + $opt.global | should -betrue + $opt.a | should -be '32bit' } it 'handles regex characters' { $a = "-?" - { $opt, $rem, $err = getopt $a 'ga:' 'global' 'arch=' } | should not throw - { $null, $null, $null = getopt $a '?:' 'help' | should not throw } + { $opt, $rem, $err = getopt $a 'ga:' 'global' 'arch=' } | should -not -throw + { $null, $null, $null = getopt $a '?:' 'help' | should -not -throw } } it 'handles short option without required argument' { $null, $null, $err = getopt '-x' 'x' '' - $err | should be $null + $err | should -benullorempty } it 'handles long option without required argument' { $opt, $null, $err = getopt '--long-arg' '' 'long-arg' - $err | should be $null - $opt."long-arg" | should be $true + $err | should -benullorempty + $opt."long-arg" | should -betrue } it 'handles long option with required argument' { $opt, $null, $err = getopt '--long-arg', 'test' '' 'long-arg=' - $err | should be $null - $opt."long-arg" | should be "test" + $err | should -benullorempty + $opt."long-arg" | should -be "test" } } diff --git a/test/Scoop-Linting.Tests.ps1 b/test/Scoop-Linting.Tests.ps1 index aa3f92946..40370a047 100644 --- a/test/Scoop-Linting.Tests.ps1 +++ b/test/Scoop-Linting.Tests.ps1 @@ -7,13 +7,13 @@ Describe -Tag 'Linter' "PSScriptAnalyzer" { Context "Checking ScriptAnalyzer" { It "Invoke-ScriptAnalyzer Cmdlet should exist" { - { Get-Command Invoke-ScriptAnalyzer -ErrorAction Stop } | Should Not Throw + { Get-Command Invoke-ScriptAnalyzer -ErrorAction Stop } | should -not -throw } It "PSScriptAnalyzerSettings.ps1 should exist" { - Test-Path "$repo_dir\PSScriptAnalyzerSettings.psd1" | Should Be $true + Test-Path "$repo_dir\PSScriptAnalyzerSettings.psd1" | should -betrue } It "There should be files to test" { - $scoop_modules.Count | Should Not Be 0 + $scoop_modules.Count | should -not -be 0 } } @@ -23,7 +23,7 @@ Describe -Tag 'Linter' "PSScriptAnalyzer" { foreach($directory in $scoop_modules) { $analysis = Invoke-ScriptAnalyzer -Path $directory.FullName -Settings $linting_settings.FullName It "Should pass: $directory" { - $analysis.Count | Should Be 0 + $analysis.Count | should -be 0 } if($analysis) { foreach($result in $analysis) { diff --git a/test/Scoop-Manifest.Tests.ps1 b/test/Scoop-Manifest.Tests.ps1 index 3f15dcf3d..223bf5dfe 100644 --- a/test/Scoop-Manifest.Tests.ps1 +++ b/test/Scoop-Manifest.Tests.ps1 @@ -12,34 +12,34 @@ describe -Tag 'Manifests' "manifest-validation" { } it "Scoop.Validator is available" { - ([System.Management.Automation.PSTypeName]'Scoop.Validator').Type | should be 'Scoop.Validator' + ([System.Management.Automation.PSTypeName]'Scoop.Validator').Type | should -be 'Scoop.Validator' } context "parse_json function" { it "fails with invalid json" { - { parse_json "$working_dir\broken_wget.json" } | should throw + { parse_json "$working_dir\broken_wget.json" } | should -throw } } context "schema validation" { it "fails with broken schema" { $validator = new-object Scoop.Validator("$working_dir/broken_schema.json", $true) - $validator.Validate("$working_dir/wget.json") | should be $false - $validator.Errors.Count | should be 1 - $validator.Errors | select-object -First 1 | should match "broken_schema.*(line 6).*(position 4)" + $validator.Validate("$working_dir/wget.json") | should -BeFalse + $validator.Errors.Count | should -be 1 + $validator.Errors | select-object -First 1 | should -match "broken_schema.*(line 6).*(position 4)" } it "fails with broken manifest" { $validator = new-object Scoop.Validator($schema, $true) - $validator.Validate("$working_dir/broken_wget.json") | should be $false - $validator.Errors.Count | should be 1 - $validator.Errors | select-object -First 1 | should match "broken_wget.*(line 5).*(position 4)" + $validator.Validate("$working_dir/broken_wget.json") | should -BeFalse + $validator.Errors.Count | should -be 1 + $validator.Errors | select-object -First 1 | should -match "broken_wget.*(line 5).*(position 4)" } it "fails with invalid manifest" { $validator = new-object Scoop.Validator($schema, $true) - $validator.Validate("$working_dir/invalid_wget.json") | should be $false - $validator.Errors.Count | should be 16 - $validator.Errors | select-object -First 1 | should match "invalid_wget.*randomproperty.*properties\.$" - $validator.Errors | select-object -Last 1 | should match "invalid_wget.*version\.$" + $validator.Validate("$working_dir/invalid_wget.json") | should -BeFalse + $validator.Errors.Count | should -be 16 + $validator.Errors | select-object -First 1 | should -match "invalid_wget.*randomproperty.*properties\.$" + $validator.Errors | select-object -Last 1 | should -match "invalid_wget.*version\.$" } } @@ -74,7 +74,7 @@ describe -Tag 'Manifests' "manifest-validation" { if ($validator.Errors.Count -gt 0) { write-host -f yellow $validator.ErrorsAsString } - $validator.Errors.Count | should be 0 + $validator.Errors.Count | should -be 0 } catch { if($_.exception.message -like '*The free-quota limit of 1000 schema validations per hour has been reached.*') { $quota_exceeded = $true @@ -91,7 +91,7 @@ describe -Tag 'Manifests' "manifest-validation" { if(!$url) { $url = $url64 } - $url | should not benullorempty + $url | should -not -benullorempty } } } diff --git a/test/Scoop-Versions.Tests.ps1 b/test/Scoop-Versions.Tests.ps1 index 92ef774e5..a02e96821 100644 --- a/test/Scoop-Versions.Tests.ps1 +++ b/test/Scoop-Versions.Tests.ps1 @@ -7,7 +7,7 @@ describe "versions" -Tag 'Scoop' { $b = '1.8.5-1' $res = compare_versions $a $b - $res | should be 1 + $res | should -be 1 } it 'handles plain string version comparison to int version' { @@ -15,7 +15,7 @@ describe "versions" -Tag 'Scoop' { $b = '20150405' $res = compare_versions $a $b - $res | should be 1 + $res | should -be 1 } it 'handles dashed version components' { @@ -24,14 +24,14 @@ describe "versions" -Tag 'Scoop' { $res = compare_versions $a $b - $res | should be -1 + $res | should -be -1 } it 'handles comparsion against en empty string' { - compare_versions '7.0.4-9' '' | should be 1 + compare_versions '7.0.4-9' '' | should -be 1 } it 'handles equal versions' { - compare_versions '12.0' '12.0' | should be 0 + compare_versions '12.0' '12.0' | should -be 0 } }