Based on discussion on this thread #24, I did some research and found out an easier way to test what is being printed to STDOUT and STDERR without hassles.
The solution is Open3, it's really clean!
Testing could be as simple as:
require 'open3'
...
context 'when options is non verbose' do
message, error = Open3.capture2e('hscode -c 422')
it 'prints code title only' do
expect(message).to include '422 - Unprocessable Entity'
expect(error.exitstatus).to eql 0 # or
expect(error.success?).to be true
end
end
Once this is accepted, I can go ahead cleaning up the whole test suite.
Based on discussion on this thread #24, I did some research and found out an easier way to test what is being printed to STDOUT and STDERR without hassles.
The solution is
Open3, it's really clean!Testing could be as simple as:
Once this is accepted, I can go ahead cleaning up the whole test suite.