Sha256: 8bc1c68e107116c8f79a3d125bc74756ed6c6e7f4192eb1bd3f70459f27f2f59

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

# encoding: utf-8

RSpec.describe Loaf::Translation do

  before { I18n.backend = I18n::Backend::Simple.new }

  after { I18n.backend.reload! }

  it "doesn't translate empty title" do
    expect(described_class.find_title('')).to eql('')
  end

  it "skips translation if doesn't find a matching scope" do
    expect(described_class.find_title('unknown')).to eql('unknown')
  end

  it 'translates breadcrumb title' do
    I18n.backend.store_translations 'en', loaf: { breadcrumbs: { home: 'Home'}}
    expect(described_class.find_title('home')).to eql('Home')
  end

  it 'does not translates breadcrumb name with missing scope' do
    I18n.backend.store_translations 'en', breadcrumbs: {home: 'Home'}
    expect(described_class.find_title('home')).to eql('home')
  end

  it 'translates breadcrumb name using default option' do
    expect(described_class.find_title('home', default: 'breadcrumb default name')).to eql('breadcrumb default name')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loaf-0.8.1 spec/unit/translation_spec.rb
loaf-0.8.0 spec/unit/translation_spec.rb