Skip to content

Commit

Permalink
Add FileContentMatchMultiline. (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvs authored and nohwnd committed Apr 13, 2018
1 parent 388af56 commit d7af394
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions en-US/about_Should.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ SHOULD MEMBERS
'TestDrive:\file.txt' | Should -FileContentMatch 'I am' # Test will pass
'TestDrive:\file.txt' | Should -FileContentMatch 'I Am' # Test will fail

FileContentMatchMultiline
As opposed to FileContentMatch and FileContentMatchExactly operators, FileContentMatchMultiline presents content of the file
being tested as one string object, so that the expression you are comparing it to can consist of several lines.

$Content = "I am the first line.`nI am the second line."
Set-Content -Path TestDrive:\file.txt -Value $Content -NoNewline
'TestDrive:\file.txt' | Should -FileContentMatchMultiline 'first line\.\r?\nI am' # Test will pass
'TestDrive:\file.txt' | Should -FileContentMatchMultiline '^I am the first.*\n.*second line\.$' # Test will pass.

When using FileContentMatchMultiline operator, '^' and '$' represent the beginning and end of the whole file,
instead of the beginning and end of a line.

$Content = "I am the first line.`nI am the second line."
Set-Content -Path TestDrive:\file.txt -Value $Content -NoNewline
'TestDrive:\file.txt' | Should -FileContentMatchMultiline '^I am the first line\.$' # Test will fail.


EXCEPTIONS
Throw
Expand Down

0 comments on commit d7af394

Please sign in to comment.