如何让rspec显示完整的失败痕迹

时间:2017-07-10 08:30:57

标签: rspec serverspec

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

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的全部内容,而不仅仅是文件的第一行和最后一行用“...”分隔,就像现在一样?

1 个答案:

答案 0 :(得分:1)

Using match, you can see the actual string if the test fails:

describe file('example.txt') do
  its(:content) { should match /param1 50/ }
end