File: output_wrapper_spec.rb

package info (click to toggle)
ruby-rspec 3.9.0c2e2m1s3-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,612 kB
  • sloc: ruby: 67,456; sh: 1,572; makefile: 98
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