Sha256: 7ac58793c95c3749aed3faa88c2b9b5b870b763c0aa9381ce5288478c74da094

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

# frozen_string_literal: true

shared_examples_for 'the navbar helper' do
  all_tests_pass_with 'no navbar options'
  all_tests_pass_with 'the :fluid navbar option'
  all_tests_pass_with 'the :variant navbar option'
  all_tests_pass_with 'the :text_variant navbar option'
  all_tests_pass_with 'the :position navbar option'
end

#--

shared_examples_for 'no navbar options' do
  specify 'creates a <nav> element with a nested container' do
    html = <<-EOT.strip_heredoc.strip
      <nav class="navbar bg-primary navbar-expand-lg navbar-dark" role="navigation">
        <div class="container">
          content
        </div>
      </nav>
    EOT
    expect(:navbar).to generate html
  end
end

shared_examples_for 'the :fluid navbar option' do
  Railsstrap::Navbar.layouts.each do |value, fluid_class|
    specify %(set to #{value}, sets the class "#{fluid_class}") do
      html = /<div class="#{fluid_class}">/
      expect(navbar: { fluid: value }).to generate html
    end
  end
end

shared_examples_for 'the :variant navbar option' do
  Railsstrap::Navbar.variants.each do |value, variant_class|
    specify %(set to #{value}, sets the class "#{variant_class}") do
      html = /<nav class="navbar #{variant_class}.+/
      expect(navbar: { variant: value }).to generate html
    end
  end
end

shared_examples_for 'the :text_variant navbar option' do
  Railsstrap::Navbar.text_variants.each do |value, variant_class|
    specify %(set to #{value}, sets the class "#{variant_class}") do
      html = /^<nav class="navbar(.*)navbar-dark(.*)" role="navigation"(.*)/
      expect(navbar: { variant: value }).to generate html
    end
  end
end

shared_examples_for 'the :position navbar option' do
  Railsstrap::Navbar.positions.each do |position, position_class|
    specify %(set to #{position}, sets the class "#{position_class}") do
      html = /(.*)class=".+#{position_class}"(.*)/
      expect(navbar: { position: position }).to generate html
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railsstrap-4.0.0.beta3 spec/shared/navbar_helper.rb
railsstrap-4.0.0.beta2 spec/shared/navbar_helper.rb