bootstrap-navbar 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -0
- data/lib/bootstrap-navbar.rb +1 -3
- data/lib/bootstrap-navbar/helpers/bootstrap2.rb +5 -5
- data/lib/bootstrap-navbar/helpers/bootstrap3.rb +54 -39
- data/lib/bootstrap-navbar/version.rb +1 -1
- data/spec/bootstrap-navbar/helpers/bootstrap2_spec.rb +99 -166
- data/spec/bootstrap-navbar/helpers/bootstrap3_spec.rb +88 -101
- data/spec/support/helpers.rb +3 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 781cad4ac31fafee2286b64f3724c8b5cd4a3ed2
|
4
|
+
data.tar.gz: b0d3f73b9c98ed24f2f65216d3ff313249964e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d37fed5dd7c408fb4e69cae5ee66c476dca8b96967afce12ed6d21b3a4770ac2457c6677700ba2ef5c2ea8ee670a96b8454635976d79355d9d732383be5ba8
|
7
|
+
data.tar.gz: a33caba3b1d44fedba100e33ccb2c7e167b88dbc87ddbd6a4ddae14a3be19fd5d9ed2d2dde8772550321f4deaec4a1d99a036370f42c3686a1aa22626abd7207
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
|
3
|
+
* Refactor: Add navbar_header and navbar_collapse to make it possible to insert content outside of header and collapse sections.
|
4
|
+
* Refactor: remove internal list of Bootstrap versions which had to be updated every time a new Bootstrap version was released.
|
5
|
+
* Fix: make sure options that are passed into methods are not altered
|
data/README.md
CHANGED
@@ -73,6 +73,10 @@ Since the navbar format changed quite a bit between Bootstrap 2.x and 3.x, gener
|
|
73
73
|
|
74
74
|
[Usage with Bootstrap 3.x](https://github.com/bootstrap-ruby/bootstrap-navbar/wiki/Usage-with-Bootstrap-3.x)
|
75
75
|
|
76
|
+
## Changes
|
77
|
+
|
78
|
+
See [CHANGELOG](CHANGELOG.md)
|
79
|
+
|
76
80
|
## Contributing
|
77
81
|
|
78
82
|
1. Fork it
|
data/lib/bootstrap-navbar.rb
CHANGED
@@ -3,10 +3,8 @@ require 'gem_config'
|
|
3
3
|
module BootstrapNavbar
|
4
4
|
include GemConfig::Base
|
5
5
|
|
6
|
-
BOOTSTRAP_VERSIONS = %w(3.1.0 3.0.3 3.0.2 3.0.1 3.0.0 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0)
|
7
|
-
|
8
6
|
with_configuration do
|
9
|
-
has :bootstrap_version, classes: [String, NilClass]
|
7
|
+
has :bootstrap_version, classes: [String, NilClass]
|
10
8
|
has :current_url_method, classes: String
|
11
9
|
end
|
12
10
|
end
|
@@ -8,6 +8,7 @@ module BootstrapNavbar::Helpers::Bootstrap2
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def navbar_group(options = {}, &block)
|
11
|
+
options = options.dup
|
11
12
|
css_classes = %w(nav).tap do |css_classes|
|
12
13
|
css_classes << "pull-#{options.delete(:pull)}" if options.has_key?(:pull)
|
13
14
|
css_classes << options.delete(:class) if options.has_key?(:class)
|
@@ -23,9 +24,8 @@ HTML
|
|
23
24
|
def navbar_item(name = nil, path = nil, list_item_options = nil, link_options = nil, &block)
|
24
25
|
name, path, list_item_options, link_options = capture(&block), name, path, list_item_options if block_given?
|
25
26
|
path ||= '#'
|
26
|
-
list_item_options
|
27
|
-
link_options
|
28
|
-
|
27
|
+
list_item_options = list_item_options.nil? ? {} : list_item_options.dup
|
28
|
+
link_options = link_options.nil? ? {} : link_options.dup
|
29
29
|
list_item_css_classes = [].tap do |css_classes|
|
30
30
|
css_classes << 'active' if current_url?(path)
|
31
31
|
css_classes << list_item_options.delete(:class) if list_item_options.has_key?(:class)
|
@@ -57,6 +57,7 @@ HTML
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def navbar_sub_dropdown(name, list_item_options = {}, link_options = {}, &block)
|
60
|
+
list_item_options, link_options = list_item_options.dup, link_options.dup
|
60
61
|
list_item_css_classes = %w(dropdown-submenu).tap do |css_classes|
|
61
62
|
css_classes << list_item_options.delete(:class) if list_item_options.has_key?(:class)
|
62
63
|
end
|
@@ -102,13 +103,13 @@ HTML
|
|
102
103
|
private
|
103
104
|
|
104
105
|
def wrapper(options, html_options, &block)
|
106
|
+
options, html_options = options.dup, html_options.dup
|
105
107
|
position = case
|
106
108
|
when options.has_key?(:static)
|
107
109
|
"static-#{options[:static]}"
|
108
110
|
when options.has_key?(:fixed)
|
109
111
|
"fixed-#{options[:fixed]}"
|
110
112
|
end
|
111
|
-
|
112
113
|
css_classes = %w(navbar).tap do |css_classes|
|
113
114
|
css_classes << "navbar-#{position}" if position
|
114
115
|
css_classes << 'navbar-inverse' if options[:inverse]
|
@@ -116,7 +117,6 @@ HTML
|
|
116
117
|
end
|
117
118
|
attribute_hash = { class: css_classes.join(' ') }.merge(html_options)
|
118
119
|
attributes = attributes_for_tag(attribute_hash)
|
119
|
-
|
120
120
|
prepare_html <<-HTML.chomp!
|
121
121
|
<div#{attributes}>
|
122
122
|
#{capture(&block) if block_given?}
|
@@ -1,23 +1,57 @@
|
|
1
1
|
module BootstrapNavbar::Helpers::Bootstrap3
|
2
2
|
def navbar(options = {}, &block)
|
3
|
-
|
4
|
-
|
5
|
-
collapsable(&block)
|
3
|
+
options = options.dup
|
4
|
+
container = options.has_key?(:container) ? options.delete(:container) : true
|
6
5
|
wrapper options do
|
7
|
-
|
8
|
-
container(
|
6
|
+
if container
|
7
|
+
container(container, &block)
|
9
8
|
else
|
10
|
-
|
9
|
+
capture(&block)
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
14
|
+
def navbar_header(options = {}, &block)
|
15
|
+
options = options.dup
|
16
|
+
brand, brand_link = options.delete(:brand), options.delete(:brand_link)
|
17
|
+
css_classes = %w(navbar-header).tap do |css_classes|
|
18
|
+
css_classes << options.delete(:class) if options.has_key?(:class)
|
19
|
+
end
|
20
|
+
attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
|
21
|
+
prepare_html <<-HTML.chomp!
|
22
|
+
<div#{attributes}>
|
23
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapsable">
|
24
|
+
<span class="sr-only">Toggle navigation</span>
|
25
|
+
<span class="icon-bar"></span>
|
26
|
+
<span class="icon-bar"></span>
|
27
|
+
<span class="icon-bar"></span>
|
28
|
+
</button>
|
29
|
+
#{brand_link brand, brand_link unless brand.nil?}
|
30
|
+
#{capture(&block) if block_given?}
|
31
|
+
</div>
|
32
|
+
HTML
|
33
|
+
end
|
34
|
+
|
35
|
+
def navbar_collapse(options = {}, &block)
|
36
|
+
options = options.dup
|
37
|
+
css_classes = %w(collapse navbar-collapse).tap do |css_classes|
|
38
|
+
css_classes << options.delete(:class) if options.has_key?(:class)
|
39
|
+
end
|
40
|
+
attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), id: 'navbar-collapsable'))
|
41
|
+
prepare_html <<-HTML.chomp!
|
42
|
+
<div#{attributes}>
|
43
|
+
#{capture(&block) if block_given?}
|
44
|
+
</div>
|
45
|
+
HTML
|
46
|
+
end
|
47
|
+
|
15
48
|
def navbar_group(options = {}, &block)
|
49
|
+
options = options.dup
|
16
50
|
css_classes = %w(nav navbar-nav).tap do |css_classes|
|
17
51
|
css_classes << "navbar-#{options.delete(:align)}" if options.has_key?(:align)
|
18
52
|
css_classes << options.delete(:class) if options.has_key?(:class)
|
19
53
|
end
|
20
|
-
attributes = attributes_for_tag(
|
54
|
+
attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
|
21
55
|
prepare_html <<-HTML.chomp!
|
22
56
|
<ul#{attributes}>
|
23
57
|
#{capture(&block) if block_given?}
|
@@ -28,9 +62,8 @@ HTML
|
|
28
62
|
def navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block)
|
29
63
|
text, url, list_item_options, link_options = capture(&block), text, list_item_options if block_given?
|
30
64
|
url ||= '#'
|
31
|
-
list_item_options
|
32
|
-
link_options
|
33
|
-
|
65
|
+
list_item_options = list_item_options.nil? ? {} : list_item_options.dup
|
66
|
+
link_options = link_options.nil? ? {} : link_options.dup
|
34
67
|
list_item_css_classes = [].tap do |css_classes|
|
35
68
|
css_classes << 'active' if current_url?(url)
|
36
69
|
css_classes << list_item_options.delete(:class) if list_item_options.has_key?(:class)
|
@@ -51,12 +84,13 @@ HTML
|
|
51
84
|
end
|
52
85
|
|
53
86
|
def navbar_form(options = {}, &block)
|
87
|
+
options = options.dup
|
54
88
|
css_classes = %w(navbar-form).tap do |css_classes|
|
55
89
|
css_classes << "navbar-#{options.delete(:align)}" if options.has_key?(:align)
|
56
90
|
css_classes << options.delete(:class) if options.has_key?(:class)
|
57
91
|
end
|
58
92
|
role = options.delete(:role) || 'form'
|
59
|
-
attributes = attributes_for_tag(
|
93
|
+
attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), role: role))
|
60
94
|
prepare_html <<-HTML.chomp!
|
61
95
|
<form#{attributes}>
|
62
96
|
#{capture(&block) if block_given?}
|
@@ -66,22 +100,24 @@ HTML
|
|
66
100
|
|
67
101
|
def navbar_text(text = nil, options = {}, &block)
|
68
102
|
raise StandardError, 'Please provide either the "text" parameter or a block.' if (text.nil? && !block_given?) || (!text.nil? && block_given?)
|
103
|
+
options = options.dup
|
69
104
|
text ||= capture(&block)
|
70
105
|
css_classes = %w(navbar-text).tap do |css_classes|
|
71
106
|
css_classes << options.delete(:class) if options.has_key?(:class)
|
72
107
|
end
|
73
|
-
attributes = attributes_for_tag(
|
108
|
+
attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
|
74
109
|
prepare_html <<-HTML.chomp!
|
75
110
|
<p#{attributes}>#{text}</p>
|
76
111
|
HTML
|
77
112
|
end
|
78
113
|
|
79
114
|
def navbar_button(text, options = {})
|
115
|
+
options = options.dup
|
80
116
|
css_classes = %w(btn navbar-btn).tap do |css_classes|
|
81
117
|
css_classes << options.delete(:class) if options.has_key?(:class)
|
82
118
|
end
|
83
119
|
type = options.delete(:type) || 'button'
|
84
|
-
attributes = attributes_for_tag(
|
120
|
+
attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), type: type))
|
85
121
|
prepare_html <<-HTML.chomp!
|
86
122
|
<button#{attributes}>#{text}</button>
|
87
123
|
HTML
|
@@ -114,34 +150,12 @@ HTML
|
|
114
150
|
|
115
151
|
private
|
116
152
|
|
117
|
-
def container(type,
|
153
|
+
def container(type, &block)
|
118
154
|
css_class = 'container'
|
119
155
|
css_class << "-#{type}" if type.is_a?(String)
|
120
156
|
attributes = attributes_for_tag(class: css_class)
|
121
157
|
prepare_html <<-HTML.chomp!
|
122
158
|
<div#{attributes}>
|
123
|
-
#{content}
|
124
|
-
</div>
|
125
|
-
HTML
|
126
|
-
end
|
127
|
-
|
128
|
-
def header(brand, brand_link)
|
129
|
-
prepare_html <<-HTML.chomp!
|
130
|
-
<div class="navbar-header">
|
131
|
-
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapsable">
|
132
|
-
<span class="sr-only">Toggle navigation</span>
|
133
|
-
<span class="icon-bar"></span>
|
134
|
-
<span class="icon-bar"></span>
|
135
|
-
<span class="icon-bar"></span>
|
136
|
-
</button>
|
137
|
-
#{brand_link brand, brand_link unless brand.nil?}
|
138
|
-
</div>
|
139
|
-
HTML
|
140
|
-
end
|
141
|
-
|
142
|
-
def collapsable(&block)
|
143
|
-
prepare_html <<-HTML.chomp!
|
144
|
-
<div class="collapse navbar-collapse" id="navbar-collapsable">
|
145
159
|
#{capture(&block) if block_given?}
|
146
160
|
</div>
|
147
161
|
HTML
|
@@ -157,15 +171,16 @@ HTML
|
|
157
171
|
end
|
158
172
|
|
159
173
|
def wrapper(options, &block)
|
160
|
-
|
174
|
+
options = options.dup
|
161
175
|
css_classes = %w(navbar).tap do |css_classes|
|
176
|
+
css_classes << "navbar-#{options.delete(:inverse) ? 'inverse' : 'default'}"
|
162
177
|
css_classes << "navbar-fixed-#{options.delete(:fixed)}" if options.has_key?(:fixed)
|
163
178
|
css_classes << 'navbar-static-top' if options.delete(:static)
|
164
179
|
css_classes << 'navbar-inverse' if options.delete(:inverse)
|
165
|
-
css_classes <<
|
180
|
+
css_classes << options.delete(:class) if options.has_key?(:class)
|
166
181
|
end
|
167
182
|
role = options.delete(:role) || 'navigation'
|
168
|
-
attributes = attributes_for_tag(
|
183
|
+
attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), role: role))
|
169
184
|
prepare_html <<-HTML.chomp!
|
170
185
|
<nav#{attributes}>
|
171
186
|
#{capture(&block) if block_given?}
|
@@ -2,12 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples 'active menu item' do
|
4
4
|
it 'generates the correct HTML' do
|
5
|
-
|
6
|
-
paths_and_urls.each do |
|
7
|
-
|
8
|
-
|
9
|
-
expect(renderer.navbar_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' })
|
10
|
-
end
|
5
|
+
paths_and_urls.each do |current_path_or_url|
|
6
|
+
paths_and_urls.each do |menu_path_or_url|
|
7
|
+
BootstrapNavbar.configuration.current_url_method = "'#{current_path_or_url}'"
|
8
|
+
expect(renderer.navbar_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' })
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
@@ -15,24 +13,23 @@ end
|
|
15
13
|
|
16
14
|
describe BootstrapNavbar::Helpers::Bootstrap2 do
|
17
15
|
before do
|
18
|
-
BootstrapNavbar.
|
16
|
+
BootstrapNavbar.configure do |config|
|
17
|
+
config.current_url_method = '"/"'
|
18
|
+
config.bootstrap_version = '2.0.0'
|
19
|
+
end
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'includes the correct module' do
|
22
|
-
|
23
|
-
|
24
|
-
expect(renderer.class.ancestors).to_not include(BootstrapNavbar::Helpers::Bootstrap3)
|
25
|
-
end
|
23
|
+
expect(renderer.class.ancestors).to include(BootstrapNavbar::Helpers::Bootstrap2)
|
24
|
+
expect(renderer.class.ancestors).to_not include(BootstrapNavbar::Helpers::Bootstrap3)
|
26
25
|
end
|
27
26
|
|
28
27
|
describe '#navbar' do
|
29
28
|
context 'without parameters' do
|
30
29
|
it 'generates the correct HTML' do
|
31
|
-
|
32
|
-
|
33
|
-
with_tag :div, with: { class: '
|
34
|
-
with_tag :div, with: { class: 'container' }
|
35
|
-
end
|
30
|
+
expect(renderer.navbar).to have_tag(:div, with: { class: 'navbar' }) do
|
31
|
+
with_tag :div, with: { class: 'navbar-inner' } do
|
32
|
+
with_tag :div, with: { class: 'container' }
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
@@ -40,61 +37,49 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
|
|
40
37
|
|
41
38
|
context 'with a block' do
|
42
39
|
it 'generates the correct HTML' do
|
43
|
-
|
44
|
-
expect(renderer.navbar { 'foo' }).to have_tag(:div, with: { class: 'navbar' }, text: /foo/)
|
45
|
-
end
|
40
|
+
expect(renderer.navbar { 'foo' }).to have_tag(:div, with: { class: 'navbar' }, text: /foo/)
|
46
41
|
end
|
47
42
|
end
|
48
43
|
|
49
44
|
context 'with "static" parameter' do
|
50
45
|
it 'generates the correct HTML' do
|
51
|
-
|
52
|
-
|
53
|
-
expect(renderer.navbar(static: 'bottom')).to have_tag(:div, with: { class: 'navbar navbar-static-bottom' })
|
54
|
-
end
|
46
|
+
expect(renderer.navbar(static: 'top')).to have_tag(:div, with: { class: 'navbar navbar-static-top' })
|
47
|
+
expect(renderer.navbar(static: 'bottom')).to have_tag(:div, with: { class: 'navbar navbar-static-bottom' })
|
55
48
|
end
|
56
49
|
end
|
57
50
|
|
58
51
|
context 'with "fixed" parameter' do
|
59
52
|
it 'generates the correct HTML' do
|
60
|
-
|
61
|
-
|
62
|
-
expect(renderer.navbar(fixed: 'bottom')).to have_tag(:div, with: { class: 'navbar navbar-fixed-bottom' })
|
63
|
-
end
|
53
|
+
expect(renderer.navbar(fixed: 'top')).to have_tag(:div, with: { class: 'navbar navbar-fixed-top' })
|
54
|
+
expect(renderer.navbar(fixed: 'bottom')).to have_tag(:div, with: { class: 'navbar navbar-fixed-bottom' })
|
64
55
|
end
|
65
56
|
end
|
66
57
|
|
67
58
|
context 'with "inverse" parameter' do
|
68
59
|
it 'generates the correct HTML' do
|
69
|
-
|
70
|
-
expect(renderer.navbar(inverse: true)).to have_tag(:div, with: { class: 'navbar navbar-inverse' })
|
71
|
-
end
|
60
|
+
expect(renderer.navbar(inverse: true)).to have_tag(:div, with: { class: 'navbar navbar-inverse' })
|
72
61
|
end
|
73
62
|
end
|
74
63
|
|
75
64
|
context 'with "brand" and "brank_link" parameters' do
|
76
65
|
it 'generates the correct HTML' do
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
expect(renderer.navbar(brand_link: 'http://google.com')).to have_tag(:a, with: { href: 'http://google.com', class: 'brand' })
|
81
|
-
end
|
66
|
+
expect(renderer.navbar(brand: 'foo')).to have_tag(:a, with: { href: '/', class: 'brand' }, text: /foo/)
|
67
|
+
expect(renderer.navbar(brand: 'foo', brand_link: 'http://google.com')).to have_tag(:a, with: { href: 'http://google.com', class: 'brand' }, text: /foo/)
|
68
|
+
expect(renderer.navbar(brand_link: 'http://google.com')).to have_tag(:a, with: { href: 'http://google.com', class: 'brand' })
|
82
69
|
end
|
83
70
|
end
|
84
71
|
|
85
72
|
context 'with "responsive" parameter' do
|
86
73
|
it 'generates the correct HTML' do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
with_tag :span, with: { class: 'icon-bar' }
|
91
|
-
end
|
74
|
+
expect(renderer.navbar(responsive: true)).to have_tag(:a, with: { class: 'btn btn-navbar', :'data-toggle' => 'collapse', :'data-target' => '.nav-collapse' }) do
|
75
|
+
3.times do
|
76
|
+
with_tag :span, with: { class: 'icon-bar' }
|
92
77
|
end
|
93
78
|
end
|
94
|
-
|
79
|
+
with_bootstrap_versions %w(2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2) do
|
95
80
|
expect(renderer.navbar(responsive: true)).to have_tag(:div, with: { class: 'nav-collapse collapse' })
|
96
81
|
end
|
97
|
-
|
82
|
+
with_bootstrap_versions %w(2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1) do
|
98
83
|
expect(renderer.navbar(responsive: true)).to have_tag(:div, with: { class: 'nav-collapse' })
|
99
84
|
end
|
100
85
|
end
|
@@ -102,17 +87,13 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
|
|
102
87
|
|
103
88
|
context 'with "fluid" parameter' do
|
104
89
|
it 'generates the correct HTML' do
|
105
|
-
|
106
|
-
expect(renderer.navbar(fluid: true)).to have_tag(:div, with: { class: 'container-fluid' })
|
107
|
-
end
|
90
|
+
expect(renderer.navbar(fluid: true)).to have_tag(:div, with: { class: 'container-fluid' })
|
108
91
|
end
|
109
92
|
end
|
110
93
|
|
111
94
|
context 'with wrapper parameters' do
|
112
95
|
it 'generates the correct HTML' do
|
113
|
-
|
114
|
-
expect(renderer.navbar({}, class: 'my-wrapper-class', id: 'my-wrapper-id')).to have_tag(:div, with: { class: 'navbar my-wrapper-class', id: 'my-wrapper-id' })
|
115
|
-
end
|
96
|
+
expect(renderer.navbar({}, class: 'my-wrapper-class', id: 'my-wrapper-id')).to have_tag(:div, with: { class: 'navbar my-wrapper-class', id: 'my-wrapper-id' })
|
116
97
|
end
|
117
98
|
end
|
118
99
|
end
|
@@ -120,42 +101,32 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
|
|
120
101
|
describe '#navbar_group' do
|
121
102
|
context 'without parameters' do
|
122
103
|
it 'generates the correct HTML' do
|
123
|
-
|
124
|
-
|
125
|
-
expect(renderer.navbar_group { 'foo' }).to have_tag(:ul, with: { class: 'nav' }, text: /foo/)
|
126
|
-
end
|
104
|
+
expect(renderer.navbar_group).to have_tag(:ul, with: { class: 'nav' })
|
105
|
+
expect(renderer.navbar_group { 'foo' }).to have_tag(:ul, with: { class: 'nav' }, text: /foo/)
|
127
106
|
end
|
128
107
|
end
|
129
108
|
|
130
109
|
context 'with "pull" parameter' do
|
131
110
|
it 'generates the correct HTML' do
|
132
|
-
|
133
|
-
expect(renderer.navbar_group(pull: 'right')).to have_tag(:ul, with: { class: 'nav pull-right' })
|
134
|
-
end
|
111
|
+
expect(renderer.navbar_group(pull: 'right')).to have_tag(:ul, with: { class: 'nav pull-right' })
|
135
112
|
end
|
136
113
|
end
|
137
114
|
|
138
115
|
context 'with "class" parameter' do
|
139
116
|
it 'generates the correct HTML' do
|
140
|
-
|
141
|
-
expect(renderer.navbar_group(class: 'foo')).to have_tag(:ul, with: { class: 'nav foo' })
|
142
|
-
end
|
117
|
+
expect(renderer.navbar_group(class: 'foo')).to have_tag(:ul, with: { class: 'nav foo' })
|
143
118
|
end
|
144
119
|
end
|
145
120
|
|
146
121
|
context 'with random parameters' do
|
147
122
|
it 'generates the correct HTML' do
|
148
|
-
|
149
|
-
expect(renderer.navbar_group(:'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav', :'data-foo' => 'bar' })
|
150
|
-
end
|
123
|
+
expect(renderer.navbar_group(:'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav', :'data-foo' => 'bar' })
|
151
124
|
end
|
152
125
|
end
|
153
126
|
|
154
127
|
context 'with many parameters' do
|
155
128
|
it 'generates the correct HTML' do
|
156
|
-
|
157
|
-
expect(renderer.navbar_group(pull: 'right', class: 'foo', :'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav foo pull-right', :'data-foo' => 'bar' })
|
158
|
-
end
|
129
|
+
expect(renderer.navbar_group(pull: 'right', class: 'foo', :'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav foo pull-right', :'data-foo' => 'bar' })
|
159
130
|
end
|
160
131
|
end
|
161
132
|
end
|
@@ -208,31 +179,25 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
|
|
208
179
|
|
209
180
|
context 'with list item options' do
|
210
181
|
it 'generates the correct HTML' do
|
211
|
-
|
212
|
-
|
213
|
-
expect(renderer.navbar_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, with: { class: 'active bar', id: 'baz' })
|
214
|
-
end
|
182
|
+
BootstrapNavbar.configuration.current_url_method = '"/"'
|
183
|
+
expect(renderer.navbar_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, with: { class: 'active bar', id: 'baz' })
|
215
184
|
end
|
216
185
|
end
|
217
186
|
|
218
187
|
context 'with link options' do
|
219
188
|
it 'generates the correct HTML' do
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
with_tag :a, with: { href: '/', class: 'pelle', id: 'fant' }, text: /foo/
|
224
|
-
end
|
189
|
+
BootstrapNavbar.configuration.current_url_method = '"/"'
|
190
|
+
expect(renderer.navbar_item('foo', '/', {}, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'active' }) do
|
191
|
+
with_tag :a, with: { href: '/', class: 'pelle', id: 'fant' }, text: /foo/
|
225
192
|
end
|
226
193
|
end
|
227
194
|
end
|
228
195
|
|
229
196
|
context 'with list item options and link options' do
|
230
197
|
it 'generates the correct HTML' do
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
with_tag :a, with: { href: '/', class: 'pelle', id: 'fant' }, text: /foo/
|
235
|
-
end
|
198
|
+
BootstrapNavbar.configuration.current_url_method = '"/"'
|
199
|
+
expect(renderer.navbar_item('foo', '/', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'active bar', id: 'baz' }) do
|
200
|
+
with_tag :a, with: { href: '/', class: 'pelle', id: 'fant' }, text: /foo/
|
236
201
|
end
|
237
202
|
end
|
238
203
|
end
|
@@ -240,69 +205,57 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
|
|
240
205
|
|
241
206
|
context 'without current URL' do
|
242
207
|
it 'generates the correct HTML' do
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
with_tag :a, with: { href: '/foo' }, text: /foo/
|
257
|
-
end
|
208
|
+
BootstrapNavbar.configuration.current_url_method = '"/foo"'
|
209
|
+
expect(renderer.navbar_item('foo')).to have_tag(:li, without: { class: 'active' }) do
|
210
|
+
with_tag :a, with: { href: '#' }, text: /foo/
|
211
|
+
end
|
212
|
+
expect(renderer.navbar_item('foo', '/')).to have_tag(:li, without: { class: 'active' }) do
|
213
|
+
with_tag :a, with: { href: '/' }, text: /foo/
|
214
|
+
end
|
215
|
+
expect(renderer.navbar_item('foo', '/bar')).to have_tag(:li, without: { class: 'active' }) do
|
216
|
+
with_tag :a, with: { href: '/bar' }, text: /foo/
|
217
|
+
end
|
218
|
+
BootstrapNavbar.configuration.current_url_method = '"/"'
|
219
|
+
expect(renderer.navbar_item('foo', '/foo')).to have_tag(:li, without: { class: 'active' }) do
|
220
|
+
with_tag :a, with: { href: '/foo' }, text: /foo/
|
258
221
|
end
|
259
222
|
end
|
260
223
|
|
261
224
|
context 'with list item options' do
|
262
225
|
it 'generates the correct HTML' do
|
263
|
-
|
264
|
-
|
265
|
-
expect(renderer.navbar_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, without: { class: 'active' }, with: { class: 'bar', id: 'baz' })
|
266
|
-
end
|
226
|
+
BootstrapNavbar.configuration.current_url_method = '"/foo"'
|
227
|
+
expect(renderer.navbar_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, without: { class: 'active' }, with: { class: 'bar', id: 'baz' })
|
267
228
|
end
|
268
229
|
end
|
269
230
|
end
|
270
231
|
|
271
232
|
context 'with a block' do
|
272
233
|
it 'generates the correct HTML' do
|
273
|
-
|
274
|
-
|
275
|
-
with_tag :a, with: { href: '#' }, text: /bar/
|
276
|
-
end
|
234
|
+
expect(renderer.navbar_item { 'bar' }).to have_tag(:li) do
|
235
|
+
with_tag :a, with: { href: '#' }, text: /bar/
|
277
236
|
end
|
278
237
|
end
|
279
238
|
|
280
239
|
context 'with list item options' do
|
281
240
|
it 'generates the correct HTML' do
|
282
|
-
|
283
|
-
|
284
|
-
with_tag :a, with: { href: '/foo' }, text: /bar/
|
285
|
-
end
|
241
|
+
expect(renderer.navbar_item('/foo', class: 'pelle', id: 'fant') { 'bar' }).to have_tag(:li, with: { class: 'pelle', id: 'fant' }) do
|
242
|
+
with_tag :a, with: { href: '/foo' }, text: /bar/
|
286
243
|
end
|
287
244
|
end
|
288
245
|
end
|
289
246
|
|
290
247
|
context 'with link options' do
|
291
248
|
it 'generates the correct HTML' do
|
292
|
-
|
293
|
-
|
294
|
-
with_tag :a, with: { href: '/foo', class: 'pelle', id: 'fant' }, text: /bar/
|
295
|
-
end
|
249
|
+
expect(renderer.navbar_item('/foo', {}, class: 'pelle', id: 'fant') { 'bar' }).to have_tag(:li) do
|
250
|
+
with_tag :a, with: { href: '/foo', class: 'pelle', id: 'fant' }, text: /bar/
|
296
251
|
end
|
297
252
|
end
|
298
253
|
end
|
299
254
|
|
300
255
|
context 'with list item options and link options' do
|
301
256
|
it 'generates the correct HTML' do
|
302
|
-
|
303
|
-
|
304
|
-
with_tag :a, with: { href: '/foo', class: 'pelle', id: 'fant' }, text: /shnoo/
|
305
|
-
end
|
257
|
+
expect(renderer.navbar_item('/foo', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant') { 'shnoo' }).to have_tag(:li, with: { class: 'bar', id: 'baz' }) do
|
258
|
+
with_tag :a, with: { href: '/foo', class: 'pelle', id: 'fant' }, text: /shnoo/
|
306
259
|
end
|
307
260
|
end
|
308
261
|
end
|
@@ -318,67 +271,57 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
|
|
318
271
|
|
319
272
|
describe '#navbar_dropdown' do
|
320
273
|
it 'generates the correct HTML' do
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
with_tag :b, with: { class: 'caret' }
|
326
|
-
end
|
327
|
-
with_dropdown_menu
|
274
|
+
expect(renderer.navbar_dropdown('foo')).to have_tag(:li, with: { class: 'dropdown' }) do
|
275
|
+
with_tag :a, with: { href: '#', class: 'dropdown-toggle', :'data-toggle' => 'dropdown' } do
|
276
|
+
with_text /foo/
|
277
|
+
with_tag :b, with: { class: 'caret' }
|
328
278
|
end
|
279
|
+
with_dropdown_menu
|
280
|
+
end
|
329
281
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
end
|
335
|
-
with_dropdown_menu('bar')
|
282
|
+
expect(renderer.navbar_dropdown('foo') { 'bar' }).to have_tag(:li, with: { class: 'dropdown' }) do
|
283
|
+
with_tag :a, with: { href: '#', class: 'dropdown-toggle', :'data-toggle' => 'dropdown' } do
|
284
|
+
with_text /foo/
|
285
|
+
with_tag :b, with: { class: 'caret' }
|
336
286
|
end
|
287
|
+
with_dropdown_menu('bar')
|
337
288
|
end
|
338
289
|
end
|
339
290
|
end
|
340
291
|
|
341
292
|
describe '#navbar_sub_dropdown' do
|
342
293
|
it 'generates the correct HTML' do
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
end
|
294
|
+
expect(renderer.navbar_sub_dropdown('foo')).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
|
295
|
+
with_tag :a, with: { href: '#' }, text: /foo/
|
296
|
+
with_dropdown_menu
|
297
|
+
end
|
348
298
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
end
|
299
|
+
expect(renderer.navbar_sub_dropdown('foo') { 'bar' }).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
|
300
|
+
with_tag :a, with: { href: '#' }, text: /foo/
|
301
|
+
with_dropdown_menu('bar')
|
353
302
|
end
|
354
303
|
end
|
355
304
|
|
356
305
|
context 'with list item options' do
|
357
306
|
it 'generates the correct HTML' do
|
358
|
-
|
359
|
-
|
360
|
-
with_tag :a, with: { href: '#' }, text: /foo/
|
361
|
-
end
|
307
|
+
expect(renderer.navbar_sub_dropdown('foo', class: 'bar', id: 'baz')).to have_tag(:li, with: { class: 'dropdown-submenu bar', id: 'baz' }) do
|
308
|
+
with_tag :a, with: { href: '#' }, text: /foo/
|
362
309
|
end
|
363
310
|
end
|
364
311
|
end
|
365
312
|
|
366
313
|
context 'with link options' do
|
367
314
|
it 'generates the correct HTML' do
|
368
|
-
|
369
|
-
|
370
|
-
with_tag :a, with: { href: '#', class: 'pelle', id: 'fant' }, text: /foo/
|
371
|
-
end
|
315
|
+
expect(renderer.navbar_sub_dropdown('foo', {}, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
|
316
|
+
with_tag :a, with: { href: '#', class: 'pelle', id: 'fant' }, text: /foo/
|
372
317
|
end
|
373
318
|
end
|
374
319
|
end
|
375
320
|
|
376
321
|
context 'with list item options and link options' do
|
377
322
|
it 'generates the correct HTML' do
|
378
|
-
|
379
|
-
|
380
|
-
with_tag :a, with: { href: '#', class: 'pelle', id: 'fant' }, text: /foo/
|
381
|
-
end
|
323
|
+
expect(renderer.navbar_sub_dropdown('foo', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'dropdown-submenu bar', id: 'baz' }) do
|
324
|
+
with_tag :a, with: { href: '#', class: 'pelle', id: 'fant' }, text: /foo/
|
382
325
|
end
|
383
326
|
end
|
384
327
|
end
|
@@ -387,45 +330,35 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
|
|
387
330
|
|
388
331
|
describe '#navbar_dropdown_divider' do
|
389
332
|
it 'generates the correct HTML' do
|
390
|
-
|
391
|
-
expect(renderer.navbar_dropdown_divider).to have_tag(:li, with: { class: 'divider' }, text: '')
|
392
|
-
end
|
333
|
+
expect(renderer.navbar_dropdown_divider).to have_tag(:li, with: { class: 'divider' }, text: '')
|
393
334
|
end
|
394
335
|
end
|
395
336
|
|
396
337
|
describe '#navbar_dropdown_header' do
|
397
338
|
it 'generates the correct HTML' do
|
398
|
-
|
399
|
-
expect(renderer.navbar_dropdown_header('foo')).to have_tag(:li, with: { class: 'nav-header' }, text: /foo/)
|
400
|
-
end
|
339
|
+
expect(renderer.navbar_dropdown_header('foo')).to have_tag(:li, with: { class: 'nav-header' }, text: /foo/)
|
401
340
|
end
|
402
341
|
end
|
403
342
|
|
404
343
|
describe '#navbar_divider' do
|
405
344
|
it 'generates the correct HTML' do
|
406
|
-
|
407
|
-
expect(renderer.navbar_divider).to have_tag(:li, with: { class: 'divider-vertical' }, text: '')
|
408
|
-
end
|
345
|
+
expect(renderer.navbar_divider).to have_tag(:li, with: { class: 'divider-vertical' }, text: '')
|
409
346
|
end
|
410
347
|
end
|
411
348
|
|
412
349
|
describe '#navbar_text' do
|
413
350
|
it 'generates the correct HTML' do
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
expect(renderer.navbar_text(nil, 'left') { 'foo' }).to have_tag(:p, with: { class: 'navbar-text pull-left' }, text: /foo/)
|
419
|
-
end
|
351
|
+
expect(renderer.navbar_text('foo')).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
|
352
|
+
expect(renderer.navbar_text { 'foo' }).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
|
353
|
+
expect(renderer.navbar_text('foo', 'right')).to have_tag(:p, with: { class: 'navbar-text pull-right' }, text: /foo/)
|
354
|
+
expect(renderer.navbar_text(nil, 'left') { 'foo' }).to have_tag(:p, with: { class: 'navbar-text pull-left' }, text: /foo/)
|
420
355
|
end
|
421
356
|
end
|
422
357
|
|
423
358
|
describe '#navbar_brand_link' do
|
424
359
|
it 'generates the correct HTML' do
|
425
|
-
|
426
|
-
|
427
|
-
expect(renderer.navbar_brand_link('foo', '/foo')).to have_tag(:a, with: { class: 'brand', href: '/foo' }, text: /foo/)
|
428
|
-
end
|
360
|
+
expect(renderer.navbar_brand_link('foo')).to have_tag(:a, with: { class: 'brand', href: '/' }, text: /foo/)
|
361
|
+
expect(renderer.navbar_brand_link('foo', '/foo')).to have_tag(:a, with: { class: 'brand', href: '/foo' }, text: /foo/)
|
429
362
|
end
|
430
363
|
end
|
431
364
|
end
|
@@ -2,13 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples 'active navbar link' do
|
4
4
|
it 'generates the correct HTML' do
|
5
|
-
|
6
|
-
paths_and_urls.each do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
with_tag :a, with: { href: menu_path_or_url }, text: /foo/
|
11
|
-
end
|
5
|
+
paths_and_urls.each do |current_path_or_url|
|
6
|
+
paths_and_urls.each do |menu_path_or_url|
|
7
|
+
BootstrapNavbar.configuration.current_url_method = "'#{current_path_or_url}'"
|
8
|
+
expect(renderer.navbar_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' }) do
|
9
|
+
with_tag :a, with: { href: menu_path_or_url }, text: /foo/
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -17,56 +15,52 @@ end
|
|
17
15
|
|
18
16
|
describe BootstrapNavbar::Helpers::Bootstrap3 do
|
19
17
|
before do
|
20
|
-
BootstrapNavbar.
|
18
|
+
BootstrapNavbar.configure do |config|
|
19
|
+
config.current_url_method = '"/"'
|
20
|
+
config.bootstrap_version = '3.0.0'
|
21
|
+
end
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'includes the correct module' do
|
24
|
-
|
25
|
-
|
26
|
-
expect(renderer.class.ancestors).to_not include(BootstrapNavbar::Helpers::Bootstrap2)
|
27
|
-
end
|
25
|
+
expect(renderer.class.ancestors).to include(BootstrapNavbar::Helpers::Bootstrap3)
|
26
|
+
expect(renderer.class.ancestors).to_not include(BootstrapNavbar::Helpers::Bootstrap2)
|
28
27
|
end
|
29
28
|
|
30
29
|
describe '#navbar' do
|
31
30
|
context 'without parameters' do
|
32
31
|
it 'generates the correct HTML' do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
32
|
+
expect(renderer.navbar { 'foo' }).to have_tag(:nav, with: { class: 'navbar navbar-default', role: 'navigation' }, text: /foo/)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with "inverse" parameter' do
|
37
|
+
it 'generates the correct HTML' do
|
38
|
+
expect(renderer.navbar(inverse: true)).to have_tag(:nav, with: { class: 'navbar navbar-inverse' })
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with "fixed" parameter' do
|
43
|
+
it 'generates the correct HTML' do
|
44
|
+
expect(renderer.navbar(fixed: 'top')).to have_tag(:nav, with: { class: 'navbar navbar-default navbar-fixed-top' })
|
45
|
+
expect(renderer.navbar(fixed: 'bottom')).to have_tag(:nav, with: { class: 'navbar navbar-default navbar-fixed-bottom' })
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
51
49
|
context 'with "static" parameter' do
|
52
50
|
it 'generates the correct HTML' do
|
53
|
-
|
54
|
-
expect(renderer.navbar(static: true)).to have_tag(:nav, with: { class: 'navbar navbar-default navbar-static-top' })
|
55
|
-
end
|
51
|
+
expect(renderer.navbar(static: true)).to have_tag(:nav, with: { class: 'navbar navbar-default navbar-static-top' })
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
55
|
context 'with "container" parameter' do
|
60
56
|
it 'generates the correct HTML' do
|
61
|
-
|
62
|
-
|
63
|
-
with_tag :div, with: { class: 'container' }
|
64
|
-
end
|
65
|
-
expect(renderer.navbar(container: false)).to have_tag(:nav, with: { class: 'navbar navbar-default' }) do
|
66
|
-
without_tag :div, with: { class: 'container' }
|
67
|
-
end
|
57
|
+
expect(renderer.navbar(container: true)).to have_tag(:nav, with: { class: 'navbar navbar-default' }) do
|
58
|
+
with_tag :div, with: { class: 'container' }
|
68
59
|
end
|
69
|
-
|
60
|
+
expect(renderer.navbar(container: false)).to have_tag(:nav, with: { class: 'navbar navbar-default' }) do
|
61
|
+
without_tag :div, with: { class: 'container' }
|
62
|
+
end
|
63
|
+
with_bootstrap_versions %w(3.1.0) do
|
70
64
|
expect(renderer.navbar(container: 'fluid')).to have_tag(:nav, with: { class: 'navbar navbar-default' }) do
|
71
65
|
with_tag :div, with: { class: 'container-fluid' }
|
72
66
|
end
|
@@ -74,29 +68,46 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
|
|
74
68
|
end
|
75
69
|
end
|
76
70
|
|
77
|
-
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#navbar_header',:focus do
|
74
|
+
context 'without parameters' do
|
78
75
|
it 'generates the correct HTML' do
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
expect(renderer.navbar_header { 'foo' }).to have_tag :div, with: { class: 'navbar-header' } do
|
77
|
+
with_tag :button, with: { type: 'button', class: 'navbar-toggle', :'data-toggle' => 'collapse', :'data-target' => '#navbar-collapsable' } do
|
78
|
+
with_tag :span, with: { class: 'sr-only' }, text: /Toggle navigation/
|
79
|
+
3.times do
|
80
|
+
with_tag :span, with: { class: 'icon-bar' }
|
81
|
+
end
|
82
|
+
end
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
86
|
-
context 'with "
|
87
|
+
context 'with "brand" and "brank_link" parameters' do
|
87
88
|
it 'generates the correct HTML' do
|
88
|
-
|
89
|
-
|
90
|
-
end
|
89
|
+
expect(renderer.navbar_header(brand: 'foo')).to have_tag(:a, with: { href: '/', class: 'navbar-brand' }, text: /foo/)
|
90
|
+
expect(renderer.navbar_header(brand: 'foo', brand_link: 'http://google.com')).to have_tag(:a, with: { href: 'http://google.com', class: 'navbar-brand' }, text: /foo/)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
context 'with "
|
94
|
+
context 'with "class" parameter' do
|
95
95
|
it 'generates the correct HTML' do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
expect(renderer.navbar_header(class: 'bar')).to have_tag :div, with: { class: 'navbar-header bar' }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#navbar_collapse',:focus do
|
102
|
+
context 'without parameters' do
|
103
|
+
it 'generates the correct HTML' do
|
104
|
+
expect(renderer.navbar_collapse { 'foo' }).to have_tag :div, with: { class: 'collapse navbar-collapse', id: 'navbar-collapsable' }, text: /foo/
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'with "class" parameter' do
|
109
|
+
it 'generates the correct HTML' do
|
110
|
+
expect(renderer.navbar_collapse(class: 'bar')).to have_tag :div, with: { class: 'collapse navbar-collapse bar', id: 'navbar-collapsable' }
|
100
111
|
end
|
101
112
|
end
|
102
113
|
end
|
@@ -104,32 +115,26 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
|
|
104
115
|
describe '#navbar_group' do
|
105
116
|
context 'without parameters' do
|
106
117
|
it 'generates the correct HTML' do
|
107
|
-
|
108
|
-
expect(renderer.navbar_group).to have_tag(:ul, with: { class: 'nav navbar-nav' })
|
109
|
-
end
|
118
|
+
expect(renderer.navbar_group).to have_tag(:ul, with: { class: 'nav navbar-nav' })
|
110
119
|
end
|
111
120
|
end
|
112
121
|
|
113
122
|
context 'with "align" parameter' do
|
114
123
|
it 'generates the correct HTML' do
|
115
|
-
|
116
|
-
|
117
|
-
expect(renderer.navbar_group(align: 'left')).to have_tag(:ul, with: { class: 'nav navbar-nav navbar-left' })
|
118
|
-
end
|
124
|
+
expect(renderer.navbar_group(align: 'right')).to have_tag(:ul, with: { class: 'nav navbar-nav navbar-right' })
|
125
|
+
expect(renderer.navbar_group(align: 'left')).to have_tag(:ul, with: { class: 'nav navbar-nav navbar-left' })
|
119
126
|
end
|
120
127
|
end
|
121
128
|
end
|
122
129
|
|
123
130
|
describe '#navbar_dropdown' do
|
124
131
|
it 'generates the correct HTML' do
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
with_tag :b, with: { class: 'caret' }
|
130
|
-
end
|
131
|
-
with_tag :ul, with: { class: 'dropdown-menu' }, text: /bar/
|
132
|
+
expect(renderer.navbar_dropdown('foo') { 'bar' }).to have_tag(:li, with: { class: 'dropdown' }) do
|
133
|
+
with_tag :a, with: { href: '#', class: 'dropdown-toggle', :'data-toggle' => 'dropdown' } do
|
134
|
+
with_text 'foo '
|
135
|
+
with_tag :b, with: { class: 'caret' }
|
132
136
|
end
|
137
|
+
with_tag :ul, with: { class: 'dropdown-menu' }, text: /bar/
|
133
138
|
end
|
134
139
|
end
|
135
140
|
end
|
@@ -183,18 +188,16 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
|
|
183
188
|
|
184
189
|
context 'without current URL' do
|
185
190
|
it 'generates the correct HTML' do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
with_tag :a, with: { href: '/foo' }, text: /foo/
|
197
|
-
end
|
191
|
+
BootstrapNavbar.configuration.current_url_method = '"/foo"'
|
192
|
+
expect(renderer.navbar_item('foo', '/')).to have_tag(:li, without: { class: 'active' }) do
|
193
|
+
with_tag :a, with: { href: '/' }, text: /foo/
|
194
|
+
end
|
195
|
+
expect(renderer.navbar_item('foo', '/bar')).to have_tag(:li, without: { class: 'active' }) do
|
196
|
+
with_tag :a, with: { href: '/bar' }, text: /foo/
|
197
|
+
end
|
198
|
+
BootstrapNavbar.configuration.current_url_method = '"/"'
|
199
|
+
expect(renderer.navbar_item('foo', '/foo')).to have_tag(:li, without: { class: 'active' }) do
|
200
|
+
with_tag :a, with: { href: '/foo' }, text: /foo/
|
198
201
|
end
|
199
202
|
end
|
200
203
|
end
|
@@ -203,17 +206,13 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
|
|
203
206
|
describe '#navbar_form' do
|
204
207
|
context 'without parameters' do
|
205
208
|
it 'generates the correct HTML' do
|
206
|
-
|
207
|
-
expect(renderer.navbar_form { 'foo' }).to have_tag(:form, with: { class: 'navbar-form', role: 'form' }, text: /foo/)
|
208
|
-
end
|
209
|
+
expect(renderer.navbar_form { 'foo' }).to have_tag(:form, with: { class: 'navbar-form', role: 'form' }, text: /foo/)
|
209
210
|
end
|
210
211
|
end
|
211
212
|
|
212
213
|
context 'with "align" parameter' do
|
213
214
|
it 'generates the correct HTML' do
|
214
|
-
|
215
|
-
expect(renderer.navbar_form(align: 'left') { 'foo' }).to have_tag(:form, with: { class: 'navbar-form navbar-left', role: 'form' }, text: /foo/)
|
216
|
-
end
|
215
|
+
expect(renderer.navbar_form(align: 'left') { 'foo' }).to have_tag(:form, with: { class: 'navbar-form navbar-left', role: 'form' }, text: /foo/)
|
217
216
|
end
|
218
217
|
end
|
219
218
|
end
|
@@ -221,33 +220,25 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
|
|
221
220
|
describe '#navbar_text' do
|
222
221
|
context 'without parameters' do
|
223
222
|
it 'raises an error' do
|
224
|
-
|
225
|
-
expect { renderer.navbar_text }.to raise_error(StandardError, 'Please provide either the "text" parameter or a block.')
|
226
|
-
end
|
223
|
+
expect { renderer.navbar_text }.to raise_error(StandardError, 'Please provide either the "text" parameter or a block.')
|
227
224
|
end
|
228
225
|
end
|
229
226
|
|
230
227
|
context 'with "text" parameter and a block' do
|
231
228
|
it 'raises an error' do
|
232
|
-
|
233
|
-
expect { renderer.navbar_text }.to raise_error(StandardError, 'Please provide either the "text" parameter or a block.')
|
234
|
-
end
|
229
|
+
expect { renderer.navbar_text }.to raise_error(StandardError, 'Please provide either the "text" parameter or a block.')
|
235
230
|
end
|
236
231
|
end
|
237
232
|
|
238
233
|
context 'with "text" parameter' do
|
239
234
|
it 'generates the correct HTML' do
|
240
|
-
|
241
|
-
expect(renderer.navbar_text('foo')).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
|
242
|
-
end
|
235
|
+
expect(renderer.navbar_text('foo')).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
|
243
236
|
end
|
244
237
|
end
|
245
238
|
|
246
239
|
context 'with block' do
|
247
240
|
it 'generates the correct HTML' do
|
248
|
-
|
249
|
-
expect(renderer.navbar_text { 'foo' }).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
|
250
|
-
end
|
241
|
+
expect(renderer.navbar_text { 'foo' }).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
|
251
242
|
end
|
252
243
|
end
|
253
244
|
end
|
@@ -255,17 +246,13 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
|
|
255
246
|
describe '#navbar_button' do
|
256
247
|
context 'without parameters' do
|
257
248
|
it 'generates the correct HTML' do
|
258
|
-
|
259
|
-
expect(renderer.navbar_button('foo')).to have_tag(:button, with: { class: 'btn navbar-btn', type: 'button' }, text: /foo/)
|
260
|
-
end
|
249
|
+
expect(renderer.navbar_button('foo')).to have_tag(:button, with: { class: 'btn navbar-btn', type: 'button' }, text: /foo/)
|
261
250
|
end
|
262
251
|
end
|
263
252
|
|
264
253
|
context 'with "class" parameter' do
|
265
254
|
it 'generates the correct HTML' do
|
266
|
-
|
267
|
-
expect(renderer.navbar_button('foo', class: 'bar')).to have_tag(:button, with: { class: 'btn navbar-btn bar', type: 'button' }, text: /foo/)
|
268
|
-
end
|
255
|
+
expect(renderer.navbar_button('foo', class: 'bar')).to have_tag(:button, with: { class: 'btn navbar-btn bar', type: 'button' }, text: /foo/)
|
269
256
|
end
|
270
257
|
end
|
271
258
|
end
|
data/spec/support/helpers.rb
CHANGED
@@ -8,22 +8,9 @@ module Helpers
|
|
8
8
|
end.new
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def with_all_3_dot_x_versions(&block)
|
16
|
-
with_versions '3'...'4', &block
|
17
|
-
end
|
18
|
-
|
19
|
-
def with_version(version, &block)
|
20
|
-
with_versions version..version, &block
|
21
|
-
end
|
22
|
-
|
23
|
-
def with_versions(versions, &block)
|
24
|
-
BootstrapNavbar::BOOTSTRAP_VERSIONS.each do |version|
|
25
|
-
next unless versions.cover?(version)
|
26
|
-
puts "Testing version #{version}..."
|
11
|
+
def with_bootstrap_versions(versions, &block)
|
12
|
+
versions.each do |version|
|
13
|
+
puts "Testing Bootstrap version #{version}..."
|
27
14
|
BootstrapNavbar.configuration.bootstrap_version = version
|
28
15
|
block.call
|
29
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-navbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -115,6 +115,7 @@ extensions: []
|
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
117
|
- .travis.yml
|
118
|
+
- CHANGELOG.md
|
118
119
|
- Gemfile
|
119
120
|
- Guardfile
|
120
121
|
- LICENSE.txt
|