Sha256: 87817b9fc5777c49c7010f2836d3908f9f8cc184665cc29df684c92a661d37f7

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require_relative '../../test_helper'
require_relative '../../../lib/lovely_rufus/layers/one_letter_gluer'
require_relative '../../../lib/lovely_rufus/wrap'

module LovelyRufus
  module Layers
    describe OneLetterGluer do
      describe '#call' do
        it 'replaces spaces after one-letter words with non-break spaces' do
          text = 'I go crazy when I hear a cymbal and a hi-hat'
          glue = 'I go crazy when I hear a cymbal and a hi-hat'
          olg  = OneLetterGluer.new
          _(olg.call(Wrap[text, width: 42])).must_equal Wrap[glue, width: 42]
        end

        it 'glues subsequent one-letter words' do
          text = 'one-letter words in English: a, I & o'
          glue = 'one-letter words in English: a, I & o'
          olg  = OneLetterGluer.new
          _(olg.call(Wrap[text, width: 42])).must_equal Wrap[glue, width: 42]
        end

        it 'passes the fixed text to the next layer and returns its outcome' do
          final = fake(:wrap)
          layer = fake(:layer)
          mock(layer).call(Wrap['I O U', width: 69]) { final }
          glued = OneLetterGluer.new(layer).call(Wrap['I O U', width: 69])
          _(glued).must_equal final
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lovely_rufus-1.0.0 test/lovely_rufus/layers/one_letter_gluer_test.rb
lovely_rufus-0.3.2 test/lovely_rufus/layers/one_letter_gluer_test.rb