Sha256: 29a5c48abac3b3edc032e6a0089ed919ade643aa8fe7e034f59098dc79ec35f3

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require_relative '../spec_helper'
require_relative '../../lib/lovely_rufus/one_letter_gluer'
require_relative '../../lib/lovely_rufus/wrap'

module LovelyRufus
  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lovely_rufus-0.2.1 spec/lovely_rufus/one_letter_gluer_spec.rb
lovely_rufus-0.2.0 spec/lovely_rufus/one_letter_gluer_spec.rb