Sha256: 9c90e0cf789350689ae1bf6e1aa0f4b80ba41de8377bf5bb0428994db97d5587

Contents?: true

Size: 833 Bytes

Versions: 11

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'zizia/streams/formatted_message_stream'

describe Zizia::FormattedMessageStream do
  subject(:stream)     { described_class.new(stream: fake_stream) }
  let(:fake_stream)    { [] }

  it_behaves_like 'a Zizia::MessageStream'

  describe '#stream' do
    subject(:stream) { described_class.new }

    it 'is STDOUT by default' do
      expect(stream.stream).to eq STDOUT
    end
  end

  describe '#<<' do
    it 'appends newlines by default' do
      expect { stream << 'moomin' }
        .to change { fake_stream }
        .to contain_exactly("moomin\n")
    end

    it 'uses other % formatters' do
      stream.formatter = "!!!%s!!!"

      expect { stream << 'moomin' }
        .to change { fake_stream }
        .to contain_exactly('!!!moomin!!!')
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
zizia-2.1.0.alpha.09 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.08 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.07 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.06 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.05 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.04 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.03 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.02 spec/zizia/formatted_message_stream_spec.rb
zizia-2.1.0.alpha.01 spec/zizia/formatted_message_stream_spec.rb
zizia-2.0.0.alpha.01 spec/zizia/formatted_message_stream_spec.rb
zizia-1.0.1 spec/zizia/formatted_message_stream_spec.rb