0

当我使用厨房验证运行以下失败测试时

describe command ('cat example.txt') do
    its(:stdout) { should contain('param1 50') }
    its(:stdout) { should contain('param2 77') }
end

我得到以下失败跟踪:

Command "cat example.txt"
    stdout
        should contain "param1 50"
    stdout 
        should contain "param2 77" (FAILED - 1)

Failures:

    1) Command "cat example.txt" stdout should contain "param2 77"
       On host `101.10.5.103'
       Failure/Error: its(:stdout) { should contain('param2 77') }
           expected "This is the 1st line of my file example.txt...This is the 25th and last line of my file." to contain "param2 77"

如何让 rspec 向我显示我的文件 example.txt 的全部内容,而不仅仅是文件的第一行和最后一行以“...”分隔,就像它目前所做的那样?

4

1 回答 1

1

使用match,如果测试失败,您可以看到实际的字符串:

describe file('example.txt') do
  its(:content) { should match /param1 50/ }
end
于 2017-07-10T15:24:25.587 回答