Sha256: 6c170bf1570649f4b9dca23da3ea16fb241b39dc25ae529bc0111099647013b7

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

require 'stringio'
require_relative '../spec_helper'
require_relative '../../lib/lovely_rufus/cli_wrapper'

module LovelyRufus
  describe CLIWrapper do
    describe '#run' do
      let(:text) { "all right: stop, collaborate and listen\n" }
      let(:text_wrapper) { fake(:text_wrapper, as: :class) }

      it 'reads the passed stream to TextWrapper and prints the results' do
        stub(text_wrapper).wrap(text, width: 72) { text }
        lambda do
          CLIWrapper.new(text_wrapper: text_wrapper).run StringIO.new(text)
        end.must_output text
      end

      it 'accepts the desired width and passes it to TextWrapper' do
        capture_io do
          stream = StringIO.new(text)
          CLIWrapper.new(%w(--width=22), text_wrapper: text_wrapper).run stream
        end
        text_wrapper.must_have_received :wrap, [text, { width: 22 }]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lovely_rufus-0.2.1 spec/lovely_rufus/cli_wrapper_spec.rb