Sha256: f78a0fc3be4331390281ceb444290349c5cabb9d6cf22205f6eed4c1a5f7a6ec

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

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

1 entries across 1 versions & 1 rubygems

Version Path
lovely_rufus-1.0.1 test/lovely_rufus/cli_wrapper_test.rb