Sha256: 710d6276abfa6edfda4edb4a305ea72b3b6a2c787cb62ba74d247dc605f53c60

Contents?: true

Size: 1.31 KB

Versions: 22

Compression:

Stored size: 1.31 KB

Contents

describe Nanoc::Helpers::Text, helper: true do
  describe '#excerptize' do
    subject { helper.excerptize(string, params) }

    let(:string) { 'Foo bar baz quux meow woof' }
    let(:params) { {} }

    context 'no params' do
      it 'takes 25 characters' do
        expect(subject).to eql('Foo bar baz quux meow ...')
      end
    end

    context 'perfect fit' do
      let(:params) { { length: 26 } }

      it 'does not truncate' do
        expect(subject).to eql('Foo bar baz quux meow woof')
      end
    end

    context 'long length' do
      let(:params) { { length: 27 } }

      it 'does not truncate' do
        expect(subject).to eql('Foo bar baz quux meow woof')
      end
    end

    context 'short length' do
      let(:params) { { length: 3 } }

      it 'truncates' do
        expect(subject).to eql('...')
      end
    end

    context 'length shorter than omission' do
      let(:params) { { length: 2 } }

      it 'truncates, disregarding length' do
        expect(subject).to eql('...')
      end
    end

    context 'custom omission' do
      let(:params) { { omission: '[continued]' } }

      it 'uses custom omission string' do
        expect(subject).to eql('Foo bar baz qu[continued]')
      end
    end
  end

  describe '#strip_html' do
    # TODO: test this… or get rid of it (it’s bad!)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
nanoc-4.7.9 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.8 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.7 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.6 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.5 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.4 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.3 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.2 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.1 spec/nanoc/helpers/text_spec.rb
nanoc-4.7.0 spec/nanoc/helpers/text_spec.rb
nanoc-4.6.4 spec/nanoc/helpers/text_spec.rb
nanoc-4.6.3 spec/nanoc/helpers/text_spec.rb
nanoc-4.6.2 spec/nanoc/helpers/text_spec.rb
nanoc-4.6.1 spec/nanoc/helpers/text_spec.rb
nanoc-4.6.0 spec/nanoc/helpers/text_spec.rb
nanoc-4.5.4 spec/nanoc/helpers/text_spec.rb
nanoc-4.5.3 spec/nanoc/helpers/text_spec.rb
nanoc-4.5.2 spec/nanoc/helpers/text_spec.rb
nanoc-4.5.1 spec/nanoc/helpers/text_spec.rb
nanoc-4.5.0 spec/nanoc/helpers/text_spec.rb