Sha256: 093eec59ccc5291f01c6400002a4121e27a33f469d7255435520519e914aee33

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Breadcrumby::Viewer, '.scope' do
  subject { described_class.new object }

  let!(:object) { build :school }

  context 'with default :i18n_key' do
    it 'returns a i18n scope path based on class name' do
      expect(subject.scope(object)).to eq [:breadcrumby, 'school']
    end
  end

  context 'with custom :i18n_key' do
    before do
      allow(object).to receive(:breadcrumby_options) { { i18n_key: :custom } }
    end

    it 'returns a i18n scope path based on given name' do
      expect(subject.scope(object)).to eq %i[breadcrumby custom]
    end
  end

  context 'when :include_model is false' do
    before do
      allow(object).to receive(:breadcrumby_options) { { i18n_key: :custom } }
    end

    it 'returns a i18n scope path with only root key' do
      expect(subject.scope(object, include_model: false)).to eq %i[breadcrumby]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breadcrumby-0.1.0 spec/lib/breadcrumby/models/viewer/scope_spec.rb