Sha256: 9f933273678f6c88b9d0624b7607e5d5699782a56101949758e780f6b33a60a3

Contents?: true

Size: 931 Bytes

Versions: 2

Compression:

Stored size: 931 Bytes

Contents

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

module LovelyRufus
  describe CLIWrapper do
    describe '#run' do
      let(:stream)       { StringIO.new(text)                          }
      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 stream
        end.must_output text
      end

      it 'accepts the desired width and passes it to TextWrapper' do
        capture_io do
          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

2 entries across 2 versions & 1 rubygems

Version Path
lovely_rufus-0.3.1 test/lovely_rufus/cli_wrapper_test.rb
lovely_rufus-0.3.0 test/lovely_rufus/cli_wrapper_test.rb