Skip to content

Conversation

@markwragg
Copy link
Contributor

@markwragg markwragg commented Oct 15, 2018

PR Summary

  • Modified the Pester syntax for the -Be assertion (instead of just Be) to reflect the preferred use per latest version of Pester.
  • Added an example showing use of -BeOfType to test the type of a variable.
  • Other minor changes for grammar.

PR Checklist

- Modified the Pester syntax for the `-Be` assertion (instead of just `Be`) to reflect the preferred use per latest version of Pester.
- Added an example showing use of `-BeOfType` to test the type of a variable.
- Other minor changes for grammar.
Update to WritingPesterTests.md

#### Describe
Creates a logical group of tests. All Mocks and TestDrive contents defined within a Describe block are scoped to that Describe; they will no longer be present when the Describe block exits. A `Describe block may contain any number of Context and It blocks.
Creates a logical group of tests. All Mocks and TestDrive contents defined within a Describe block are scoped to that Describe; they will no longer be present when the Describe block exits. A Describe block may contain any number of Context and It blocks.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should be - A `Describe` block


The DESCRIBE BeforeAll block is executed before any other code even though it was at the bottom of the Describe block, so if state is set elsewhere in the describe BLOCK, that state will not be visible (as the code will not yet been run). Notice, too, that the BEFOREALL block in Context is executed before any other code in that block.
Generally, you should have code reside in one of the code block elements of `[Before|After][All|Each]`, especially if those block rely on state set by free code elsewhere in the block.
The Describe BeforeAll block is executed before any other code even though it was at the bottom of the Describe block, so if state is set elsewhere in the describe BLOCK, that state will not be visible (as the code will not yet been run). Notice, too, that the BeforeAll block in Context is executed before any other code in that block.
Copy link
Collaborator

Choose a reason for hiding this comment

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

`Describe` `BeforeAll`
BLOCK -> block

@TravisEz13
Copy link
Member

You also have spelling issues. I filed the following issue on the spelling tests: #8078

TravisEz13 and others added 3 commits October 19, 2018 08:44
Co-Authored-By: markwragg <mark@wragg.io>
Co-Authored-By: markwragg <mark@wragg.io>
Co-Authored-By: markwragg <mark@wragg.io>
@TravisEz13
Copy link
Member

The PR is still failing the spelling check. FYI, I'm out of the office for the next week and will be checking GitHub less frequently.

@markwragg
Copy link
Contributor Author

It's hard to tell from the spelling test output which specific words it's failing on, but to me it looks like in each case it's Pester domain-specific words like AfterEach and BeforeEach. The page doesn't currently mark each of these as inline code (that was true before my improvements) and I don't know if doing so would make them excluded from the spelling check and/or is necessary/desirable.

I'm pretty sure this PR has not introduced any new spelling mistakes, and I think it is an improvement on the previous version of this page, so my suggestion would be to merge it and iterate with further versions for other improvements.

If you can provide more specifics on spellings that you want edited however I'm happy to implement.

@iSazonov
Copy link
Collaborator

@markwragg Please replace ' with backstick. It'll resolve all issues.
BeforeEach -> `BeforeEach`

'RequireAdminOnWindows' -> `RequireAdminOnWindows`

Copy link
Collaborator

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

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

just a couple things, but important (i think)

It "1 is really an int" {
$i = 1
$i.GetType() | Should Be "int"
$i.GetType() | Should -BeExactly "int"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should really be:
$i | Should -BeOfType [int]
and consistent with the next change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing this then makes this example a duplicate of the one that follows it. Should we just remove this example instead of we don't want to recommend checking types this way?

@TravisEz13
Copy link
Member

restarted macOS CI

@TravisEz13 TravisEz13 dismissed JamesWTruher’s stale review October 30, 2018 00:48

review is out of date

@TravisEz13 TravisEz13 merged commit 8215914 into PowerShell:master Oct 30, 2018
@iSazonov
Copy link
Collaborator

@markwragg Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants