我想提出一个失败的测试,除非字符串完全匹配。
导致失败的输出
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
应该导致成功的输出:
PS C:\Users\vagrant> auditpol.exe /get /subcategory:'User Account Management'
System audit policy
Category/Subcategory Setting
Account Management
User Account Management Success
以下测试的各种排列经过了数小时的谷歌搜索和实验
describe command("auditpol.exe /get /subcategory:'User Account Management'") do
its(:stdout){should match(/User Account Management Success/)}
end
最有希望的测试就是这个,但是它需要整个输出的精确文字匹配,而不仅仅是所讨论的字符串:
describe command("auditpol.exe /get /subcategory:'User Account Management'") do
its(:stdout){should eq(/User Account Management Success/)}
end
由于
答案 0 :(得分:1)
尝试使用$ -sign。
describe command("auditpol.exe /get /subcategory:'User Account Management'") do
its(:stdout){should match(/User Account Management Success$/)}
end