Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed some pester scoping issues and validation issues #388

Merged
merged 4 commits into from
May 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ Describe 'Brackets and Braces' {
iceberg.
#>

'____' | Should -Be [regex]::Matches('Bears Beat Bongos', '(B.+){3}').Value
'____' | Should -Be ([regex]::Matches('Bears Beat Bongos', '(B.+){3}').Value)
}

It 'does not find just one badger' {
Expand All @@ -511,7 +511,7 @@ Describe 'Brackets and Braces' {
The fancy regex name for this is a "character class".
#>

$____ | Should -Be 'End of the line' -match '[efg]$'
$____ | Should -Be ('End of the line' -match '[efg]$')
}

It 'wants you to end the string a certain way' {
Expand Down Expand Up @@ -557,18 +557,16 @@ Describe 'Meditative Examples' {
Validate a bunch of phone numbers - get rid of the non-numeric characters and check
which ones are actually the right length to be dialed.
#>
BeforeAll {
$phoneNumbers = @(
'1 425 555 1234'
'1-425-555-4321'
'1.425.555.6789'
'01234'
'+14255556789'
)

$phoneNumbers = @(
'1 425 555 1234'
'1-425-555-4321'
'1.425.555.6789'
'01234'
'+14255556789'
)

It 'sanitizes user input' {
$sanitizedNumbers = $phoneNumbers -replace '____'
$sanitizedNumbers | Should -Be @(
$sanitizedNumbers = @(
'14255551234'
'14255554321'
'14255556789'
Expand All @@ -577,7 +575,13 @@ Describe 'Meditative Examples' {
)
}

It 'validates user input' { $validPhoneNumbers = [regex]::Matches($sanitizedNumbers, '____').Value
It 'sanitizes user input' {

$phoneNumbers -replace '____' | Should -Be $sanitizedNumbers
}

It 'validates user input' {
$validPhoneNumbers = [regex]::Matches($sanitizedNumbers, '____').Value
$validPhoneNumbers | Should -Be @(
'14255551234'
'14255554321'
Expand Down