Functions/Assertions/ContainMultiline.Tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Set-StrictMode -Version Latest

InModuleScope Pester {
    Describe "PesterContainMultiline" {
        Context "when testing file contents" {
            Setup -File "test.txt" "this is line 1`nthis is line 2`nPester is awesome"
            It "returns true if the file matches the specified content on one line" {
                "$TestDrive\test.txt" | Should ContainMultiline  "Pester"
            }

            It "returns true if the file matches the specified content across multiple lines" {
                "$TestDrive\test.txt" | Should ContainMultiline  "line 2`nPester"
            }

            It "returns false if the file does not contain the specified content" {
                "$TestDrive\test.txt" | Should Not ContainMultiline  "Pastor"
            }
        }
    }
}