Sha256: 3a874f1c53ab7335ba853477bd2231110bcddf9e94c8a3211b11052018a0048c

Contents?: true

Size: 691 Bytes

Versions: 4

Compression:

Stored size: 691 Bytes

Contents

require 'spec_helper'

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

  context 'when set to nil' do
    before { DaruLite.error_stream = nil }
    it { expect { DaruLite.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 { DaruLite.error_stream = custom_stream }

    it 'calls puts' do
      expect { DaruLite.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

4 entries across 4 versions & 1 rubygems

Version Path
daru_lite-0.1.3 spec/daru_lite_spec.rb
daru_lite-0.1.2 spec/daru_lite_spec.rb
daru_lite-0.1.1 spec/daru_lite_spec.rb
daru_lite-0.1 spec/daru_lite_spec.rb