Sha256: b46f88e88ca8b192c7ad8990becaaadb52c7dd7bb59ed1d8ceec54f23bd25954
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Breadcrumby::Viewer, '.link_options' do subject { described_class.new object } let!(:object) { build :school } before do allow(subject).to receive(:i18n_name).with(object) { :i18n_name } end context 'when action is not given' do let!(:action) { nil } before do allow(I18n).to receive(:t).with(:title, scope: [:breadcrumby, 'school'], name: :i18n_name, default: 'title') { 'breadcrumby.school.title' } allow(I18n).to receive(:t).with(:title, scope: [:breadcrumby]) { 'title' } end it 'returns the link options' do expect(subject.link_options(object, action)).to eq( itemprop: :item, itemscope: true, itemtype: 'http://schema.org/Thing', title: 'breadcrumby.school.title' ) end end context 'when action is given' do let!(:action) { :edit } before do allow(I18n).to receive(:t).with('actions.edit.title', scope: [:breadcrumby, 'school'], name: :i18n_name, default: 'breadcrumby.actions.edit.title') { 'breadcrumby.school.actions.edit.title' } allow(I18n).to receive(:t).with('actions.edit.title', scope: [:breadcrumby]) { 'breadcrumby.actions.edit.title' } end it 'returns the link options with title scoped by action fetched from i18n with root fallback' do expect(subject.link_options(object, action)).to eq( itemprop: :item, itemscope: true, itemtype: 'http://schema.org/Thing', title: 'breadcrumby.school.actions.edit.title' ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
breadcrumby-0.1.0 | spec/lib/breadcrumby/models/viewer/link_options_spec.rb |