Sha256: f76b1305a6088b3d02001359a9d65350f6806e700ba603860299836aca8dba6e
Contents?: true
Size: 1.34 KB
Versions: 18
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true 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
18 entries across 18 versions & 1 rubygems