Sha256: 834b546fe112744d0645a6975879e587a080ad49c643f9508662fa67b3b6dee1

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe Spotlight::TitleHelper, type: :helper do
  before do
    allow(helper).to receive_messages(application_name: 'Application')
  end

  describe '#page_title' do
    it 'sets the @page_title ivar' do
      helper.page_title('Section', 'Title')
      title = helper.instance_variable_get(:@page_title)
      expect(title).to eq 'Section - Title | Application'
    end

    it 'renders the section title and the page title' do
      title = helper.page_title('Section', 'Title')
      expect(title).to have_selector 'h1', text: 'Section'
      expect(title).to have_selector 'h1 small', text: 'Title'
    end
  end

  describe '#set_html_page_title' do
    it 'assigns the @page_title ivar' do
      allow(helper).to receive_messages(application_name: 'B')
      helper.set_html_page_title 'A'
      title = helper.instance_variable_get(:@page_title)
      expect(title).to eq 'A | B'
    end
    it 'strips out any HTML tags' do
      allow(helper).to receive_messages(application_name: 'B')
      expect(helper.set_html_page_title('<b>text</b> should not include HTML')).to eq 'text should not include HTML | B'
    end
  end

  describe '#curation_page_title' do
    it 'renders a page title in the curation section' do
      title = helper.curation_page_title 'Some title'
      expect(title).to have_selector 'h1', text: 'Curation'
      expect(title).to have_selector 'h1 small', text: 'Some title'
    end
  end

  describe '#administration_page_title' do
    it 'renders a page title in the administration section' do
      title = helper.administration_page_title 'Some title'
      expect(title).to have_selector 'h1', text: 'Administration'
      expect(title).to have_selector 'h1 small', text: 'Some title'
    end
  end

  describe '#header_with_count' do
    it 'merges the title with a count label' do
      val = helper.header_with_count 'some title', 5
      expect(val).to include 'some title'
      expect(val).to have_selector 'span.label', text: 5
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
blacklight-spotlight-0.8.2 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-0.8.1 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-0.8.0 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-0.7.2 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-0.7.1 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-0.7.0 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-0.6.0 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-0.5.0 spec/helpers/spotlight/title_helper_spec.rb