spec/bootstrap-navbar/helpers/bootstrap3_spec.rb in bootstrap-navbar-2.0.0 vs spec/bootstrap-navbar/helpers/bootstrap3_spec.rb in bootstrap-navbar-2.1.0
- old
+ new
@@ -1,20 +1,7 @@
require 'spec_helper'
-shared_examples 'active navbar link' do
- it 'generates the correct HTML' do
- paths_and_urls.each do |current_path_or_url|
- paths_and_urls.each do |menu_path_or_url|
- BootstrapNavbar.configuration.current_url_method = "'#{current_path_or_url}'"
- expect(renderer.navbar_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' }) do
- with_tag :a, with: { href: menu_path_or_url }, text: /foo/
- end
- end
- end
- end
-end
-
describe BootstrapNavbar::Helpers::Bootstrap3 do
before do
BootstrapNavbar.configure do |config|
config.current_url_method = '"/"'
config.bootstrap_version = '3.0.0'
@@ -65,14 +52,13 @@
with_tag :div, with: { class: 'container-fluid' }
end
end
end
end
-
end
- describe '#navbar_header',:focus do
+ describe '#navbar_header' do
context 'without parameters' do
it 'generates the correct HTML' do
expect(renderer.navbar_header { 'foo' }).to have_tag :div, with: { class: 'navbar-header' } do
with_tag :button, with: { type: 'button', class: 'navbar-toggle', :'data-toggle' => 'collapse', :'data-target' => '#navbar-collapsable' } do
with_tag :span, with: { class: 'sr-only' }, text: /Toggle navigation/
@@ -96,11 +82,11 @@
expect(renderer.navbar_header(class: 'bar')).to have_tag :div, with: { class: 'navbar-header bar' }
end
end
end
- describe '#navbar_collapse',:focus do
+ describe '#navbar_collapse' do
context 'without parameters' do
it 'generates the correct HTML' do
expect(renderer.navbar_collapse { 'foo' }).to have_tag :div, with: { class: 'collapse navbar-collapse', id: 'navbar-collapsable' }, text: /foo/
end
end
@@ -138,54 +124,10 @@
end
end
end
describe '#navbar_item' do
- context 'with current URL or path' do
- # With root URL or path
- it_behaves_like 'active navbar link' do
- let(:paths_and_urls) do
- %w(
- http://www.foobar.com/
- http://www.foobar.com
- /
- http://www.foobar.com/?foo=bar
- http://www.foobar.com?foo=bar
- /?foo=bar
- http://www.foobar.com/#foo
- http://www.foobar.com#foo
- /#foo
- http://www.foobar.com/#foo?foo=bar
- http://www.foobar.com#foo?foo=bar
- /#foo?foo=bar
- )
- end
- end
-
- # With sub URL or path
- it_behaves_like 'active navbar link' do
- let(:paths_and_urls) do
- %w(
- http://www.foobar.com/foo
- http://www.foobar.com/foo/
- /foo
- /foo/
- http://www.foobar.com/foo?foo=bar
- http://www.foobar.com/foo/?foo=bar
- /foo?foo=bar
- /foo/?foo=bar
- http://www.foobar.com/foo#foo
- http://www.foobar.com/foo/#foo
- /foo#foo
- /foo/#foo
- http://www.foobar.com/foo#foo?foo=bar
- http://www.foobar.com/foo/#foo?foo=bar
- /foo#foo?foo=bar
- /foo/#foo?foo=bar
- )
- end
- end
- end
+ it_behaves_like 'marking the menu items as active correctly'
context 'without current URL' do
it 'generates the correct HTML' do
BootstrapNavbar.configuration.current_url_method = '"/foo"'
expect(renderer.navbar_item('foo', '/')).to have_tag(:li, without: { class: 'active' }) do