<commit_before>require 'spec_helper'
require 'padrino-helpers'

describe BootstrapNavbar::Helpers do
  subject do
    Class.new do
      include Padrino::Helpers::OutputHelpers
      include BootstrapNavbar::Helpers
    end.new
  end

  before do
    BootstrapNavbar.current_url_method = ''
  end

  describe '#nav_bar' do
    context 'without parameters' do
      it 'generates the correct HTML' do
        subject.nav_bar.should have_tag(:div, with: { class: 'navbar' }) do
          with_tag :div, with: { class: 'navbar-inner' } do
            with_tag :div, with: { class: 'container' }
          end
        end
      end
    end

    context '"static" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(static: 'top').should have_tag(:div, with: { class: 'navbar navbar-static-top' })
        subject.nav_bar(static: 'bottom').should have_tag(:div, with: { class: 'navbar navbar-static-bottom' })
      end
    end

    context '"fixed" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(fixed: 'top').should have_tag(:div, with: { class: 'navbar navbar-fixed-top' })
        subject.nav_bar(fixed: 'bottom').should have_tag(:div, with: { class: 'navbar navbar-fixed-bottom' })
      end
    end

    context '"inverse" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(inverse: true).should have_tag(:div, with: { class: 'navbar navbar-inverse' })
      end
    end

    context 'no parameters' do
      it 'generates the correct HTML' do
        subject.nav_bar.should have_tag(:div, with: { class: 'navbar' })
        subject.nav_bar { 'foo' }.should have_tag(:div, with: { class: 'navbar' }, content: 'foo')
      end
    end

    describe 'brand and brank_link parameters' do
      it 'generates the correct HTML' do
        subject.nav_bar(brand: 'foo').should have_tag(:a, with: { href: '/', class: 'brand' }, content: 'foo')
        subject.nav_bar(brand: 'foo', brand_link: 'http://google.com').should have_tag(:a, with: { href: 'http://google.com', class: 'brand' }, content: 'foo')
        subject.nav_bar(brand_link: 'http://google.com').should have_tag(:a, with: { href: 'http://google.com', class: 'brand' })
      end
    end

    describe '"responsive" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(responsive: true).should have_tag(:a, with: { class: 'btn btn-navbar', :'data-toggle' => 'collapse', :'data-target' => '.nav-collapse' }) do
          3.times do
            with_tag :span, with: { class: 'icon-bar' }
          end
        end
      end
    end

    describe '"fluid" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(fluid: true).should have_tag(:div, with: { class: 'container-fluid' })
      end
    end
  end

  describe '#menu_group' do
    context 'no parameters' do
      it 'generates the correct HTML' do
        subject.menu_group.should have_tag(:ul, with: { class: 'nav' })
        subject.menu_group { 'foo' }.should have_tag(:ul, with: { class: 'nav' }, content: 'foo')
      end
    end

    describe '"pull" parameter' do
      it 'generates the correct HTML' do
        subject.menu_group(pull: 'right').should have_tag(:ul, with: { class: 'nav pull-right' })
      end
    end

    describe '"class" parameter' do
      it 'generates the correct HTML' do
        subject.menu_group(class: 'foo').should have_tag(:ul, with: { class: 'nav foo' })
      end
    end

    describe 'more parameters' do
      it 'generates the correct HTML' do
        subject.menu_group(:'data-foo' => 'bar').should have_tag(:ul, with: { class: 'nav', :'data-foo' => 'bar' })
      end
    end

    describe 'many parameters' do
      it 'generates the correct HTML' do
        subject.menu_group(pull: 'right', class: 'foo', :'data-foo' => 'bar').should have_tag(:ul, with: { class: 'nav foo pull-right', :'data-foo' => 'bar' })
      end
    end
  end

  describe '#menu_item' do
    context 'with current URL' do
      it 'generates the correct HTML' do
        BootstrapNavbar.current_url_method = '"/"'
        subject.menu_item('foo', '/').should have_tag(:li, with: { class: 'active' }) do
          with_tag :a, with: { href: '/' }, content: 'foo'
        end

        BootstrapNavbar.current_url_method = '"/foo"'
        subject.menu_item('foo', '/foo').should have_tag(:li, with: { class: 'active' }) do
          with_tag :a, with: { href: '/foo' }, content: 'foo'<commit_msg>Spec wording<commit_after>require 'spec_helper'
require 'padrino-helpers'

describe BootstrapNavbar::Helpers do
  subject do
    Class.new do
      include Padrino::Helpers::OutputHelpers
      include BootstrapNavbar::Helpers
    end.new
  end

  before do
    BootstrapNavbar.current_url_method = ''
  end

  describe '#nav_bar' do
    context 'without parameters' do
      it 'generates the correct HTML' do
        subject.nav_bar.should have_tag(:div, with: { class: 'navbar' }) do
          with_tag :div, with: { class: 'navbar-inner' } do
            with_tag :div, with: { class: 'container' }
          end
        end
      end
    end

    context 'with block' do
      it 'generates the correct HTML' do
        subject.nav_bar { 'foo' }.should have_tag(:div, with: { class: 'navbar' }, content: 'foo')
      end
    end

    context 'with "static" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(static: 'top').should have_tag(:div, with: { class: 'navbar navbar-static-top' })
        subject.nav_bar(static: 'bottom').should have_tag(:div, with: { class: 'navbar navbar-static-bottom' })
      end
    end

    context 'with "fixed" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(fixed: 'top').should have_tag(:div, with: { class: 'navbar navbar-fixed-top' })
        subject.nav_bar(fixed: 'bottom').should have_tag(:div, with: { class: 'navbar navbar-fixed-bottom' })
      end
    end

    context 'with "inverse" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(inverse: true).should have_tag(:div, with: { class: 'navbar navbar-inverse' })
      end
    end

    context 'with "brand" and "brank_link" parameters' do
      it 'generates the correct HTML' do
        subject.nav_bar(brand: 'foo').should have_tag(:a, with: { href: '/', class: 'brand' }, content: 'foo')
        subject.nav_bar(brand: 'foo', brand_link: 'http://google.com').should have_tag(:a, with: { href: 'http://google.com', class: 'brand' }, content: 'foo')
        subject.nav_bar(brand_link: 'http://google.com').should have_tag(:a, with: { href: 'http://google.com', class: 'brand' })
      end
    end

    context 'with "responsive" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(responsive: true).should have_tag(:a, with: { class: 'btn btn-navbar', :'data-toggle' => 'collapse', :'data-target' => '.nav-collapse' }) do
          3.times do
            with_tag :span, with: { class: 'icon-bar' }
          end
        end
      end
    end

    context 'with "fluid" parameter' do
      it 'generates the correct HTML' do
        subject.nav_bar(fluid: true).should have_tag(:div, with: { class: 'container-fluid' })
      end
    end
  end

  describe '#menu_group' do
    context 'without parameters' do
      it 'generates the correct HTML' do
        subject.menu_group.should have_tag(:ul, with: { class: 'nav' })
        subject.menu_group { 'foo' }.should have_tag(:ul, with: { class: 'nav' }, content: 'foo')
      end
    end

    context 'with "pull" parameter' do
      it 'generates the correct HTML' do
        subject.menu_group(pull: 'right').should have_tag(:ul, with: { class: 'nav pull-right' })
      end
    end

    context 'with "class" parameter' do
      it 'generates the correct HTML' do
        subject.menu_group(class: 'foo').should have_tag(:ul, with: { class: 'nav foo' })
      end
    end

    context 'with random parameters' do
      it 'generates the correct HTML' do
        subject.menu_group(:'data-foo' => 'bar').should have_tag(:ul, with: { class: 'nav', :'data-foo' => 'bar' })
      end
    end

    context 'with many parameters' do
      it 'generates the correct HTML' do
        subject.menu_group(pull: 'right', class: 'foo', :'data-foo' => 'bar').should have_tag(:ul, with: { class: 'nav foo pull-right', :'data-foo' => 'bar' })
      end
    end
  end

  describe '#menu_item' do
    context 'with current URL' do
      it 'generates the correct HTML' do
        BootstrapNavbar.current_url_method = '"/"'
        subject.menu_item('foo', '/').should have_tag(:li, with: { class: 'active' }) do
          with_tag :a, with: { href: '/' }, content: 'foo'
        end

        BootstrapNavbar.current_url_method = '"/foo"'
        subject.menu_item('foo', '/foo').should have_tag(:li, with: { class: 'active' }) do
          with_tag :a, with: { href: '/foo' }, content: 'foo'
{'fraction_non_alphanumeric': 0.13947751990133422, 'fraction_numerical': 0.0002242403856934634, 'mean_word_length': 2.7748624629707996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5434502', 'n_tokens_mistral': 2851, 'n_tokens_neox': 2784, 'n_words': 817}