Sha256: 2c559c6b38faea32e7a3f377f0f7393d5d46d9295ce69bd59cea660e8a41626d

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

module SimpleNavigation
  module Renderer
    describe Text do
      let!(:navigation) { setup_navigation('nav_id', 'nav_class') }

      let(:item) { nil }
      let(:options) {{ level: :all }}
      let(:output) { renderer.render(navigation) }
      let(:renderer) { setup_renderer(Text, options) }

      before { select_an_item(navigation[item]) if item }

      describe '#render' do
        context 'when no item is selected' do
          it 'renders an empty string' do
            expect(output).to eq ''
          end
        end

        context 'when an item is selected' do
          let(:item) { :invoices }

          it "renders the selected item's name" do
            expect(output).to eq 'Invoices'
          end
        end

        context 'when a sub navigation item is selected' do
          before do
            navigation[:invoices].stub(selected?: true)

            navigation[:invoices]
              .sub_navigation[:unpaid]
              .stub(selected?: true, selected_by_condition?: true)
          end

          it 'separates the items with a space' do
            expect(output).to eq 'Invoices Unpaid'
          end

          context "and the :join_with option is set" do
            let(:options) {{ level: :all, join_with: ' | ' }}

            it 'separates the items with the specified separator' do
              expect(output).to eq 'Invoices | Unpaid'
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple-navigation-3.14.0 spec/lib/simple_navigation/rendering/renderer/text_spec.rb
simple-navigation-3.13.0 spec/lib/simple_navigation/rendering/renderer/text_spec.rb
simple-navigation-3.12.2 spec/lib/simple_navigation/rendering/renderer/text_spec.rb
simple-navigation-3.12.1 spec/lib/simple_navigation/rendering/renderer/text_spec.rb
simple-navigation-3.12.0 spec/lib/simple_navigation/rendering/renderer/text_spec.rb