File: output_wrapper_spec.rb

package info (click to toggle)
ruby-rspec 3.8.0c0e1m0s0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,640 kB
  • sloc: ruby: 65,844; sh: 807; makefile: 99
file content (22 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module RSpec::Core
  RSpec.describe OutputWrapper do
    let(:output) { StringIO.new }
    let(:wrapper) { OutputWrapper.new(output) }

    it 'redirects calls to the wrapped object' do
      wrapper.puts('message')
      wrapper.print('another message')
      expect(output.string).to eq("message\nanother message").and eq(wrapper.string)
    end

    describe '#output=' do
      let(:another_output) { StringIO.new }

      it 'changes the output stream' do
        wrapper.output = another_output
        wrapper.puts('message')
        expect(another_output.string).to eq("message\n")
      end
    end
  end
end