Sha256: 1daca48cd5246e680b705e80ffe8fc3374ddcaf3dc2314de6b1f4d9ea73aa5b4

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Loaf::CrumbFormatter do

  let(:formatter) { stub.extend(described_class) }
  let(:crumb) { Loaf::Crumb.new('some randome name', stub) }

  context '#format_name' do
    it 'does not capitalize by default' do
      formatted = formatter.format_name(crumb)
      formatted.should eql 'some randome name'
    end

    it 'capitalizes crumb name' do
      formatted = formatter.format_name(crumb, :capitalize => true)
      formatted.should eql 'Some randome name'
    end

    it 'shortens crumb to provided length' do
      name = 'very long name that is more that 30 characters long'
      crumb = Loaf::Crumb.new(name, stub)
      formatter.should_receive(:truncate).with(name, :length => 30).
        and_return name[0..30]
      formatter.format_name(crumb, :crumb_length => 30).should eql name[0..30]
    end

    it 'returns name error if breadcrumb name is nil' do
      crumb = Loaf::Crumb.new('', stub)
      formatter.format_name(crumb).should eql '[name-error]'
    end
  end

end # Loaf::CrumbFormatter

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loaf-0.3.0 spec/loaf/crumb_formatter_spec.rb
loaf-0.2.1 spec/loaf/crumb_formatter_spec.rb
loaf-0.2.0 spec/loaf/crumb_formatter_spec.rb