{"action":"created","issue":{"url":"https://api.github.com/repos/pester/Pester/issues/1058","repository_url":"https://api.github.com/repos/pester/Pester","labels_url":"https://api.github.com/repos/pester/Pester/issues/1058/labels{/name}","comments_url":"https://api.github.com/repos/pester/Pester/issues/1058/comments","events_url":"https://api.github.com/repos/pester/Pester/issues/1058/events","html_url":"https://github.com/pester/Pester/issues/1058","id":329538966,"node_id":"MDU6SXNzdWUzMjk1Mzg5NjY=","number":1058,"title":"Should Not Match assertion across multiple lines.","user":{"login":"ksivasenthil","id":7167802,"node_id":"MDQ6VXNlcjcxNjc4MDI=","avatar_url":"https://avatars2.githubusercontent.com/u/7167802?v=4","gravatar_id":"","url":"https://api.github.com/users/ksivasenthil","html_url":"https://github.com/ksivasenthil","followers_url":"https://api.github.com/users/ksivasenthil/followers","following_url":"https://api.github.com/users/ksivasenthil/following{/other_user}","gists_url":"https://api.github.com/users/ksivasenthil/gists{/gist_id}","starred_url":"https://api.github.com/users/ksivasenthil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksivasenthil/subscriptions","organizations_url":"https://api.github.com/users/ksivasenthil/orgs","repos_url":"https://api.github.com/users/ksivasenthil/repos","events_url":"https://api.github.com/users/ksivasenthil/events{/privacy}","received_events_url":"https://api.github.com/users/ksivasenthil/received_events","type":"User","site_admin":false},"labels":[{"id":671071142,"node_id":"MDU6TGFiZWw2NzEwNzExNDI=","url":"https://api.github.com/repos/pester/Pester/labels/More%20info%20needed","name":"More info needed","color":"006b75","default":false},{"id":671072524,"node_id":"MDU6TGFiZWw2NzEwNzI1MjQ=","url":"https://api.github.com/repos/pester/Pester/labels/Waiting%20for%20closure","name":"Waiting for closure","color":"d4c5f9","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-06-05T16:45:02Z","updated_at":"2018-06-12T00:45:38Z","closed_at":"2018-06-12T00:45:38Z","author_association":"NONE","body":"## 1. Provide a general summary of the issue in the Title above\r\nShould Not Match does not assert correctly across multiple lines.\r\nPlease review https://github.com/pester/Pester/wiki/Contributing-to-Pester prior to submitting an issue. -  [x] Reviewed\r\n\r\n## 2. Describe Your Environment\r\n\r\nOperating System, Pester version and PowerShell version:\r\n\r\n```powershell\r\n$bugReport = &{\r\n    $p = Get-Module -ListAvailable Pester\r\n    \"Pester version     : \" + $p.Version + \" \" + $p.Path\r\n    \"PowerShell version : \" + $PSVersionTable.PSVersion\r\n    \"OS version         : \" + [System.Environment]::OSVersion.VersionString\r\n}\r\n$bugReport\r\n$bugReport | clip\r\n```\r\nPester version     :  3.4.0 C:\\Program Files\\WindowsPowerShell\\Modules\\Pester\\3.4.0\\Pester.psm1\r\nPowerShell version : 5.1.17134.48\r\nOS version         : Microsoft Windows NT 10.0.17134.0\r\n\r\n## 3. Expected Behavior\r\n\r\nIf you're describing a bug, tell us what should happen. [x] Yes\r\n\r\nI have put the code in Current Behavior. The assert \"Should Not Match\" should fail.\r\n\r\nIf you're suggesting a change/improvement, tell us how it should work. Especially what the proposed feature is, why it is useful, and what dependencies (if any) it has. It would also be great if you added one or two examples of real world usage, if you have any. [x] No\r\n\r\n## 4.Current Behavior\r\n\r\n```powershell\r\n      \r\n$FileListWithMultipleLineCommented = @(\r\n    @{\r\n            \"Path\" = \"HelloWorld.js\";\r\n            \"CommentToken\" = \"/\\*(.*)?\\*/\"\r\n    }\r\n);\r\n\r\n$MultiLineCommentFileConent1=@\"\r\n                                /*This is Hello World comment;\r\n                                Spanning multiple lines */\r\n                                function HelloWorld() {\r\n                                    //No ref;\r\n                                }\r\n\"@;\r\n\r\n\tDescribe -Name 'Remove comments' -Description \"Validate removal of  comment blocks from the code.\" -Fixture {\r\n    Context -Name 'Multiline comments' -Fixture {\r\n        It 'Comments should be removed' -TestCase $FileListWithMultipleLineCommented {\r\n            param($Path, $CommentToken)\r\n            Mock Get-Content -Verifiable -MockWith { return $MultiLineCommentFileConent1;}\r\n            \r\n            <#The following assert should fail because the -replace operator does not have anything to replace with. Thus the original string will be returned and the Should Not Match with the same pattern should fail; since the string does still contain all the multi line comment block.#>\r\n\r\n            (Get-Content -Path $Path) -replace $CommentToken | Select-Object -Property @{n=\"File\";e={$Path}}, @{n=\"Content\";e={$_}} | Select-Object -ExpandProperty Content | Should Not Match $CommentToken\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n## 5. Possible Solution\r\n\r\nHave a solution in mind? [x]Yes\r\n\r\nhttps://github.com/pester/Pester/wiki/Contributing-to-Pester has detailed instructions on how to contribute.  [x] Reviewed\r\n\r\n## Suggestion\r\n\r\nFunctions/Assertions/Match.ps1@2 has -match operator. Instead of that operator can we use Select-String with AllMatches switch enabled?\r\n\r\n## 6. Context\r\n\r\nHow has this issue affected you? What are you trying to accomplish?\r\n\r\nI was trying to remove multiple lines of comment from a code base. While doing this I ventured into Pester to test my commands and bumped into this problem. So, actually all my tests will succeed because of the Should Not Match not looking across multiple lines.\r\n"},"comment":{"url":"https://api.github.com/repos/pester/Pester/issues/comments/396430352","html_url":"https://github.com/pester/Pester/issues/1058#issuecomment-396430352","issue_url":"https://api.github.com/repos/pester/Pester/issues/1058","id":396430352,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjQzMDM1Mg==","user":{"login":"ksivasenthil","id":7167802,"node_id":"MDQ6VXNlcjcxNjc4MDI=","avatar_url":"https://avatars2.githubusercontent.com/u/7167802?v=4","gravatar_id":"","url":"https://api.github.com/users/ksivasenthil","html_url":"https://github.com/ksivasenthil","followers_url":"https://api.github.com/users/ksivasenthil/followers","following_url":"https://api.github.com/users/ksivasenthil/following{/other_user}","gists_url":"https://api.github.com/users/ksivasenthil/gists{/gist_id}","starred_url":"https://api.github.com/users/ksivasenthil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksivasenthil/subscriptions","organizations_url":"https://api.github.com/users/ksivasenthil/orgs","repos_url":"https://api.github.com/users/ksivasenthil/repos","events_url":"https://api.github.com/users/ksivasenthil/events{/privacy}","received_events_url":"https://api.github.com/users/ksivasenthil/received_events","type":"User","site_admin":false},"created_at":"2018-06-12T00:45:38Z","updated_at":"2018-06-12T00:45:38Z","author_association":"NONE","body":"@mikeclayton  Thank you. I noticed a problem with the regex. The correct regex pattern should be \"(?s)/\\*(.*)?*/\" in my test. Since, this is not an issue with pester I am closing the issue."}}
{"actor":{"display_login":"ksivasenthil"}}