Sha256: 5c2ee40a45cd789da9d9381820753e4a29786d13b757bb1bd4e4d00f67c6035e

Contents?: true

Size: 986 Bytes

Versions: 3

Compression:

Stored size: 986 Bytes

Contents

# encoding: utf-8

RSpec.describe Loaf::CrumbFormatter, '.format_name' do
  let(:formatter) {
    Class.new do
      extend Loaf::CrumbFormatter

      def self.truncate(name, options)
        name
      end
    end
  }

  it 'returns name error if breadcrumb name is nil' do
    expect(formatter.format_name('')).to eql('')
  end

  it "doesn't capitalize by default" do
    name = 'some random name'
    formatted = formatter.format_name(name)
    expect(formatted).to eql(name)
  end

  it 'capitalizes crumb name with capitalize option' do
    name = 'some random name'
    formatted = formatter.format_name(name, capitalize: true)
    expect(formatted).to eql('Some random name')
  end

  it 'shortens crumb to provided length' do
    name = 'very long name that is more that 30 characters long'
    allow(formatter).to receive(:truncate).with(name, length: 30).
      and_return(name[0..30])
    expect(formatter.format_name(name, crumb_length: 30)).to eql(name[0..30])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loaf-0.7.0 spec/unit/crumb_formatter_spec.rb
loaf-0.6.2 spec/unit/crumb_formatter_spec.rb
loaf-0.6.1 spec/unit/crumb_formatter_spec.rb