0

When I run the following failing test with kitchen verify

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

I get the following failure trace :

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"

How can I get rspec to show me the full content of my file example.txt, and not only the first and last line of the file separating by "..." as it currently does?

B. Kev1n
  • 9
  • 2

1 Answers1

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
minamijoyo
  • 3,305
  • 1
  • 18
  • 20
  • That would be a workaround, thank you. However in some specific cases the content of my file is actually fully shown, and using 'match' would then make it appear twice (one time in the "Diff" part followed by one other time). This looks messy. I was wondering whether an option to always or never show the content of my file existed. – B. Kev1n Jul 12 '17 at 08:04