Sha256: 942f0660cab06e207d7f6a4f8c2d3f589c1ba3f476ad61fd3ae13cd0fff47cca

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 Bytes

Contents

require_relative '../spec_helper'

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
      wrap = <<-end.dedent
        all right: stop,
        collaborate and listen
      end
      stub(text_wrapper).wrap(text, width: 22) { wrap }
      lambda do
        stream = StringIO.new text
        CLIWrapper.new(%w(--width 22), text_wrapper: text_wrapper).run stream
      end.must_output wrap
    end
  end
end end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lovely_rufus-0.1.2 spec/lovely_rufus/cli_wrapper_spec.rb
lovely_rufus-0.1.1 spec/lovely_rufus/cli_wrapper_spec.rb