Reputation: 695
I would like to come up with a test which would fail, unless the string matches exactly.
Output which should lead to a failure
PS C:\Users\vagrant> auditpol.exe /get /subcategory:'User Account Management'
System audit policy
Category/Subcategory Setting
Account Management
User Account Management Success and Failure
Output which should lead to success:
PS C:\Users\vagrant> auditpol.exe /get /subcategory:'User Account Management'
System audit policy
Category/Subcategory Setting
Account Management
User Account Management Success
And various permutations of below test which passes despite hours of googling and experimenting
describe command("auditpol.exe /get /subcategory:'User Account Management'") do
its(:stdout){should match(/User Account Management Success/)}
end
The most promising test is this, however it wants the exact literal match of entire output, not just the string in question:
describe command("auditpol.exe /get /subcategory:'User Account Management'") do
its(:stdout){should eq(/User Account Management Success/)}
end
Thanks
Upvotes: 1
Views: 1930
Reputation: 76
try to work with the $-sign.
describe command("auditpol.exe /get /subcategory:'User Account Management'") do
its(:stdout){should match(/User Account Management Success$/)}
end
sources: http://www.regular-expressions.info/anchors.html and many many more
Upvotes: 1