diff --git a/spec/lib/docbookrx/docbookrx_spec.rb b/spec/lib/docbookrx/docbookrx_spec.rb index 5e701fa..b8545fd 100644 --- a/spec/lib/docbookrx/docbookrx_spec.rb +++ b/spec/lib/docbookrx/docbookrx_spec.rb @@ -474,9 +474,11 @@ | Dam |=== EOS - output = Docbookrx.convert input - - expect(output).to include(expected) + capture_stdio do |_, stderr| + output = Docbookrx.convert input + expect(output).to include(expected) + expect(stderr.string).to include('5 columns specified in table \'Control parameters\', but only 4 headers') + end end it 'should convert nested program listings in listitems correctly' do diff --git a/spec/support/extensions/helpers.rb b/spec/support/extensions/helpers.rb new file mode 100644 index 0000000..6979961 --- /dev/null +++ b/spec/support/extensions/helpers.rb @@ -0,0 +1,15 @@ +require 'stringio' + +module RSpec::Support::Helpers + def capture_stdio + old_stdout, $stdout = $stdout, StringIO.new + old_stderr, $stderr = $stderr, StringIO.new + yield $stdout, $stderr + ensure + $stdout, $stderr = old_stdout, old_stderr + end +end + +RSpec.configure do |config| + config.include RSpec::Support::Helpers +end