Sha256: 9fdbdcd5175e81c0c416017d80faeb91b1259f5fe568165ca25463c5d40d8a7a

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

# encoding: UTF-8

require 'spec_helper'
require 'action_dispatch'
require 'bh/helpers/nav_helper'

include Bh::NavHelper

describe 'nav' do
  let(:html) { nav options, &block }
  let(:block) { Proc.new {} }
  let(:options) { {} }

  describe 'with the :as option' do
    specify 'not set, shows a "tabs" nav' do
      expect(html).to include 'ul class="nav nav-tabs" role="tablist"'
    end

    context 'set to :tabs, shows a "tabs" nav' do
      let(:options) { {as: :tabs} }
      it { expect(html).to include 'ul class="nav nav-tabs"' }
    end

    context 'set to :pills, shows a "tabs" nav' do
      let(:options) { {as: :pills} }
      it { expect(html).to include 'ul class="nav nav-pills"' }
    end
  end

  describe 'with the :layout option' do
    specify 'not set, does not set a layout' do
      expect(html).to include 'ul class="nav nav-tabs" role="tablist"'
    end

    context 'set to :justified, shows a "justified" nav' do
      let(:options) { {layout: :justified} }
      it { expect(html).to include 'nav-justified' }
    end

    context 'set to :stacked, shows a "stacked" nav' do
      let(:options) { {layout: :stacked} }
      it { expect(html).to include 'nav-stacked' }
    end
  end

  describe 'given a +link_to+ in the content' do
    let(:block) { Proc.new { link_to 'Home', url} }
    let(:url) { '/any-page' }
    let(:request) { ActionDispatch::Request.new request_options }
    let(:request_options) { {'REQUEST_METHOD' => 'GET'} }

    specify 'surrounds the link in a list item' do
      expect(html).to include '<li><a href="/any-page">Home</a></li>'
    end

    context 'sets the "active" class if the link points to the same page' do
      let(:url) { '' }
      it { expect(html).to include 'li class="active"' }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bh-0.0.7 spec/helpers/nav_helper_spec.rb