Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed tags
  • Loading branch information
TimCurwick authored Jun 28, 2017
commit 0190477c734e7a788812a945a0c2830e4cc753ca
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Describe "Script with a class definition run path" {
Describe "Script with a class definition run path" -Tags "CI" {

It "Script with a class definition can run from a path without a comma" -Tags "CI" {
It "Script with a class definition can run from a path without a comma" {

$FilePath = '.\MyTest.ps1'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use $TestDrive for temporary files.


Expand All @@ -20,7 +20,7 @@ Describe "Script with a class definition run path" {
$Success | Should Be $True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid Should Be $True - this results in a typically unhelpful message in the log.

I suggest a test that actually uses the class, so maybe something like:

Instead, try something like:

`@
class MyClass { static [string]$MyProperty = $PSScriptRoot }
[MyClass]::MyProperty
'@ > $testDrive/My,Test.ps1

& $testDrive/My,Test.ps1 | Should Match ".*My,Test.ps1"

Or something like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$PSScriptRoot doesn't work inside a class.

}

It "Script with a class definition can run from a path with a comma" -Tags "CI" {
It "Script with a class definition can run from a path with a comma" {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as above test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two test cases can be combined into 1 using the -TestCases parameter for It. Example:


$FilePath = '.\My,Test.ps1'

Expand Down