Sha256: edab7d1060879ae5f9ee0448facc97231b54572f90528837b7623ba4fd5954c8

Contents?: true

Size: 671 Bytes

Versions: 5

Compression:

Stored size: 671 Bytes

Contents

require 'spec_helper'

describe '#error' do
  context 'by default' do
    it { expect { Daru.error('test') }.to output("test\n").to_stderr_from_any_process }
  end

  context 'when set to nil' do
    before { Daru.error_stream = nil }
    it { expect { Daru.error('test') }.not_to output('test').to_stderr_from_any_process }
  end

  context 'when set to instance of custom class' do
    let(:custom_stream) { double(puts: nil) }
    before { Daru.error_stream = custom_stream }

    it 'calls puts' do
      expect { Daru.error('test') }.not_to output('test').to_stderr_from_any_process
      expect(custom_stream).to have_received(:puts).with('test')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
daru-0.3 spec/daru_spec.rb
daru-0.2.2 spec/daru_spec.rb
daru-0.2.1 spec/daru_spec.rb
daru-0.2.0 spec/daru_spec.rb
daru-0.1.6 spec/daru_spec.rb