twitter-bootstrap-rails 2.2.8 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of twitter-bootstrap-rails might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +160 -228
- data/Rakefile +4 -6
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +279 -38
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/javascripts/twitter/bootstrap/affix.js +142 -0
- data/app/assets/javascripts/twitter/bootstrap/alert.js +92 -0
- data/app/assets/javascripts/twitter/bootstrap/button.js +110 -0
- data/app/assets/javascripts/twitter/bootstrap/carousel.js +223 -0
- data/app/assets/javascripts/twitter/bootstrap/collapse.js +170 -0
- data/app/assets/javascripts/twitter/bootstrap/dropdown.js +151 -0
- data/app/assets/javascripts/twitter/bootstrap/modal.js +280 -0
- data/app/assets/javascripts/twitter/bootstrap/popover.js +113 -0
- data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +170 -0
- data/app/assets/javascripts/twitter/bootstrap/tab.js +128 -0
- data/app/assets/javascripts/twitter/bootstrap/tooltip.js +457 -0
- data/app/assets/javascripts/twitter/bootstrap/transition.js +59 -0
- data/app/assets/javascripts/twitter/bootstrap.js +12 -13
- data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -890
- data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +2026 -787
- data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +1 -146
- data/app/helpers/bootstrap_flash_helper.rb +14 -7
- data/app/helpers/form_errors_helper.rb +22 -0
- data/app/helpers/glyph_helper.rb +8 -5
- data/app/helpers/modal_helper.rb +26 -22
- data/app/helpers/navbar_helper.rb +47 -32
- data/app/helpers/twitter_breadcrumbs_helper.rb +6 -2
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +8 -8
- data/lib/generators/bootstrap/install/install_generator.rb +3 -2
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +13 -11
- data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +5 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +27 -48
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +19 -34
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +13 -30
- data/lib/generators/bootstrap/partial/templates/_login.html.erb +2 -3
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +30 -10
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +10 -8
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +11 -9
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/index.html.erb +2 -2
- data/lib/generators/bootstrap/themed/templates/index.html.haml +2 -2
- data/lib/generators/bootstrap/themed/templates/index.html.slim +4 -5
- data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/show.html.erb +5 -7
- data/lib/generators/bootstrap/themed/templates/show.html.haml +4 -4
- data/lib/generators/bootstrap/themed/templates/show.html.slim +6 -7
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +5 -5
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +3 -3
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +4 -4
- data/lib/generators/bootstrap/themed/themed_generator.rb +2 -2
- data/lib/twitter/bootstrap/rails/breadcrumbs.rb +69 -0
- data/lib/twitter/bootstrap/rails/engine.rb +17 -10
- data/lib/twitter/bootstrap/rails/version.rb +2 -2
- data/spec/lib/breadcrumbs_spec.rb +99 -0
- data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +12 -4
- data/spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb +128 -0
- data/spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb +148 -0
- data/spec/lib/twitter_bootstrap_rails/glyph_helper_spec.rb +24 -0
- data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +15 -15
- data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +207 -173
- data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +18 -16
- data/spec/spec_helper.rb +11 -1
- data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5796 -1
- data/vendor/static-source/bootstrap.less +0 -1
- data/vendor/static-source/fontawesome.less +0 -1
- data/vendor/static-source/sprites.less +1 -1
- data/vendor/toolkit/fontawesome/bordered-pulled.less +16 -0
- data/vendor/toolkit/fontawesome/core.less +8 -126
- data/vendor/toolkit/fontawesome/fixed-width.less +6 -0
- data/vendor/toolkit/fontawesome/font-awesome.less +9 -25
- data/vendor/toolkit/fontawesome/icons.less +549 -378
- data/vendor/toolkit/fontawesome/larger.less +13 -0
- data/vendor/toolkit/fontawesome/list.less +19 -0
- data/vendor/toolkit/fontawesome/mixins.less +16 -39
- data/vendor/toolkit/fontawesome/path.less +5 -5
- data/vendor/toolkit/fontawesome/rotated-flipped.less +20 -0
- data/vendor/toolkit/fontawesome/spinning.less +29 -0
- data/vendor/toolkit/fontawesome/stacked.less +20 -0
- data/vendor/toolkit/fontawesome/variables.less +557 -731
- data/vendor/toolkit/twitter/bootstrap/alerts.less +47 -58
- data/vendor/toolkit/twitter/bootstrap/badges.less +55 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +26 -39
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +11 -9
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +168 -152
- data/vendor/toolkit/twitter/bootstrap/buttons.less +101 -170
- data/vendor/toolkit/twitter/bootstrap/carousel.less +150 -65
- data/vendor/toolkit/twitter/bootstrap/close.less +20 -19
- data/vendor/toolkit/twitter/bootstrap/code.less +38 -30
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +12 -3
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +115 -148
- data/vendor/toolkit/twitter/bootstrap/forms.less +401 -547
- data/vendor/toolkit/twitter/bootstrap/glyphicons.less +234 -0
- data/vendor/toolkit/twitter/bootstrap/grid.less +74 -11
- data/vendor/toolkit/twitter/bootstrap/input-groups.less +166 -0
- data/vendor/toolkit/twitter/bootstrap/jumbotron.less +48 -0
- data/vendor/toolkit/twitter/bootstrap/labels.less +64 -0
- data/vendor/toolkit/twitter/bootstrap/list-group.less +132 -0
- data/vendor/toolkit/twitter/bootstrap/media.less +8 -7
- data/vendor/toolkit/twitter/bootstrap/mixins/alerts.less +14 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/background-variant.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/border-radius.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/buttons.less +52 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/center-block.less +7 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/clearfix.less +22 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/forms.less +85 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/gradients.less +59 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/grid-framework.less +91 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/grid.less +122 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/hide-text.less +21 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/image.less +33 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/labels.less +12 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/list-group.less +29 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-divider.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-vertical-align.less +9 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/opacity.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/pagination.less +23 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/panels.less +24 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/progress-bar.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/reset-filter.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/resize.less +6 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/responsive-visibility.less +15 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/size.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/tab-focus.less +9 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/table-row.less +28 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/text-emphasis.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/text-overflow.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/vendor-prefixes.less +224 -0
- data/vendor/toolkit/twitter/bootstrap/mixins.less +36 -699
- data/vendor/toolkit/twitter/bootstrap/modals.less +109 -54
- data/vendor/toolkit/twitter/bootstrap/navbar.less +542 -384
- data/vendor/toolkit/twitter/bootstrap/navs.less +192 -359
- data/vendor/toolkit/twitter/bootstrap/normalize.less +425 -0
- data/vendor/toolkit/twitter/bootstrap/pager.less +46 -34
- data/vendor/toolkit/twitter/bootstrap/pagination.less +70 -105
- data/vendor/toolkit/twitter/bootstrap/panels.less +248 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +61 -61
- data/vendor/toolkit/twitter/bootstrap/print.less +101 -0
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +51 -73
- data/vendor/toolkit/twitter/bootstrap/responsive-embed.less +34 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +177 -42
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +120 -23
- data/vendor/toolkit/twitter/bootstrap/tables.less +171 -182
- data/vendor/toolkit/twitter/bootstrap/theme.less +260 -0
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +26 -43
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +49 -24
- data/vendor/toolkit/twitter/bootstrap/type.less +208 -147
- data/vendor/toolkit/twitter/bootstrap/utilities.less +33 -7
- data/vendor/toolkit/twitter/bootstrap/variables.less +761 -215
- data/vendor/toolkit/twitter/bootstrap/wells.less +7 -7
- metadata +156 -130
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +0 -117
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +0 -99
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-button.js +0 -105
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +0 -207
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +0 -167
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +0 -169
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +0 -247
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +0 -114
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +0 -162
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +0 -144
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +0 -361
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +0 -60
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +0 -335
- data/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +0 -42
- data/test/lib/breadcrumbs_test.rb +0 -75
- data/test/test_helper.rb +0 -11
- data/vendor/toolkit/fontawesome/bootstrap.less +0 -84
- data/vendor/toolkit/fontawesome/extras.less +0 -93
- data/vendor/toolkit/fontawesome/font-awesome-ie7.less +0 -1953
- data/vendor/toolkit/twitter/bootstrap/accordion.less +0 -34
- data/vendor/toolkit/twitter/bootstrap/hero-unit.less +0 -25
- data/vendor/toolkit/twitter/bootstrap/labels-badges.less +0 -84
- data/vendor/toolkit/twitter/bootstrap/layouts.less +0 -16
- data/vendor/toolkit/twitter/bootstrap/reset.less +0 -216
- data/vendor/toolkit/twitter/bootstrap/responsive-1200px-min.less +0 -28
- data/vendor/toolkit/twitter/bootstrap/responsive-767px-max.less +0 -193
- data/vendor/toolkit/twitter/bootstrap/responsive-768px-979px.less +0 -19
- data/vendor/toolkit/twitter/bootstrap/responsive-navbar.less +0 -189
- data/vendor/toolkit/twitter/bootstrap/responsive.less +0 -48
- data/vendor/toolkit/twitter/bootstrap/sprites.less +0 -197
@@ -11,161 +11,232 @@ include NavbarHelper
|
|
11
11
|
|
12
12
|
describe NavbarHelper, :type => :helper do
|
13
13
|
before do
|
14
|
-
self.
|
15
|
-
self.
|
14
|
+
allow(self).to receive(:uri_state) { :inactive }
|
15
|
+
allow(self).to receive(:root_url) { '/' }
|
16
16
|
end
|
17
17
|
describe "nav_bar" do
|
18
18
|
it "should return a basic bootstrap navbar" do
|
19
|
-
nav_bar.gsub(/\s/, '').downcase
|
19
|
+
expect(nav_bar.gsub(/\s/, '').downcase)
|
20
|
+
.to eql(BASIC_NAVBAR.gsub(/\s/, '').downcase)
|
20
21
|
end
|
21
22
|
|
22
23
|
it "should set the fixed position to top" do
|
23
|
-
nav_bar(:fixed => :top).gsub(/\s/, '').downcase
|
24
|
+
expect(nav_bar(:fixed => :top).gsub(/\s/, '').downcase)
|
25
|
+
.to eql(FIXED_TOP_NAVBAR.gsub(/\s/, '').downcase)
|
24
26
|
end
|
25
27
|
|
26
28
|
it "should set the static position to top" do
|
27
|
-
nav_bar(:static => :top).gsub(/\s/, '').downcase
|
29
|
+
expect(nav_bar(:static => :top).gsub(/\s/, '').downcase)
|
30
|
+
.to eql(STATIC_TOP_NAVBAR.gsub(/\s/, '').downcase)
|
28
31
|
end
|
29
32
|
|
30
33
|
it "should set the fixed position to bottom" do
|
31
|
-
nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase
|
34
|
+
expect(nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase)
|
35
|
+
.to eql(FIXED_BOTTOM_NAVBAR.gsub(/\s/, '').downcase)
|
32
36
|
end
|
33
37
|
|
34
38
|
it "should set the style to inverse" do
|
35
|
-
nav_bar(:inverse => true).gsub(/\s/, '').downcase
|
39
|
+
expect(nav_bar(:inverse => true).gsub(/\s/, '').downcase)
|
40
|
+
.to eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
|
36
41
|
end
|
37
42
|
|
38
43
|
it "should add the brand name and link it to the home page" do
|
39
|
-
nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase
|
44
|
+
expect(nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase)
|
45
|
+
.to eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
|
40
46
|
end
|
41
47
|
|
42
48
|
it "should be able to set the brand link url" do
|
43
|
-
nav_bar(:brand => "Ninety Ten", :brand_link => "http://www.ninetyten.com").gsub(/\s/, '').downcase
|
44
|
-
|
45
|
-
|
46
|
-
it "should set the container to fluid" do
|
47
|
-
nav_bar(:fluid => :true).gsub(/\s/, '').downcase.should eql(BASIC_NAVBAR_FLUID.gsub(/\s/, '').downcase)
|
49
|
+
expect(nav_bar(:brand => "Ninety Ten", :brand_link => "http://www.ninetyten.com").gsub(/\s/, '').downcase)
|
50
|
+
.to eql(NAVBAR_WITH_BRAND_AND_LINK.gsub(/\s/, '').downcase)
|
48
51
|
end
|
49
52
|
|
50
53
|
it "should add the buttons etc for a responsive layout with no block passed" do
|
51
|
-
nav_bar(:responsive => true).gsub(/\s/, '').downcase.
|
54
|
+
expect(nav_bar(:responsive => true).gsub(/\s/, '').downcase).to eql(RESPONSIVE_NAVBAR.gsub(/\s/, '').downcase)
|
52
55
|
end
|
53
56
|
|
54
57
|
it "should add the buttons etc for a responsive layout with block passed" do
|
55
|
-
nav_bar(:responsive => true) do
|
58
|
+
ele = nav_bar(:responsive => true) do
|
56
59
|
"<p>Passing a block</p>".html_safe
|
57
|
-
end
|
60
|
+
end
|
61
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/, '').downcase)
|
58
62
|
end
|
59
63
|
|
60
64
|
it "should render contained items" do
|
61
|
-
nav_bar do
|
65
|
+
ele = nav_bar do
|
62
66
|
menu_group do
|
63
67
|
menu_item("Home", "/") + menu_item("Products", "/products")
|
64
68
|
end
|
65
|
-
end
|
69
|
+
end
|
70
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
|
66
71
|
end
|
67
72
|
|
68
73
|
it "should still render the brand name even with other options turned on" do
|
69
|
-
nav_bar(:brand => "Something") do
|
74
|
+
ele = nav_bar(:brand => "Something") do
|
70
75
|
menu_group do
|
71
76
|
menu_item "Home", "/"
|
72
77
|
end
|
73
|
-
end
|
78
|
+
end
|
79
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
|
74
80
|
end
|
75
81
|
end
|
76
82
|
|
77
83
|
describe "menu_group" do
|
78
84
|
it "should return a ul with the class 'nav'" do
|
79
|
-
menu_group do
|
85
|
+
element = menu_group do
|
80
86
|
menu_item("Home", "/") + menu_item("Products", "/products")
|
81
|
-
end
|
87
|
+
end
|
88
|
+
|
89
|
+
expect(element).to have_tag(:ul, with: {class: "nav navbar-nav"}) {
|
90
|
+
with_tag(:li) {
|
91
|
+
with_tag(:a, text: "Home", with: {href: "/"})
|
92
|
+
}
|
93
|
+
with_tag(:li) {
|
94
|
+
with_tag(:a, text: "Products", with: {href: "/products"})
|
95
|
+
}
|
96
|
+
}
|
82
97
|
end
|
83
98
|
|
84
|
-
it "should return a ul with class .
|
85
|
-
menu_group(:
|
99
|
+
it "should return a ul with class .navbar-left when passed the {pull: :left} option" do
|
100
|
+
element = menu_group(pull: :left) do
|
86
101
|
menu_item("Home", "/")
|
87
|
-
end
|
102
|
+
end
|
103
|
+
|
104
|
+
expect(element).to have_tag(:ul, with: {class: "nav navbar-nav navbar-left"}) {
|
105
|
+
with_tag(:li) {
|
106
|
+
with_tag(:a, text: "Home", with: {href: "/"})
|
107
|
+
}
|
108
|
+
}
|
88
109
|
end
|
89
110
|
end
|
90
111
|
|
91
112
|
describe "menu_item" do
|
92
113
|
it "should return a link within an li tag" do
|
93
|
-
self.
|
94
|
-
|
114
|
+
allow(self).to receive(:current_page?) { false }
|
115
|
+
|
116
|
+
element = menu_item("Home", "/")
|
117
|
+
expect(element).to have_tag(:li) {
|
118
|
+
with_tag(:a, text: "Home", with: { href: "/" })
|
119
|
+
}
|
95
120
|
end
|
121
|
+
|
96
122
|
it "should return the link with class 'active' if on current page" do
|
97
|
-
self.
|
98
|
-
|
123
|
+
allow(self).to receive(:uri_state) { :active }
|
124
|
+
|
125
|
+
element = menu_item("Home", "/")
|
126
|
+
expect(element).to have_tag(:li, with: {class: "active"}) {
|
127
|
+
with_tag(:a, text: "Home", with: { href: "/" })
|
128
|
+
}
|
99
129
|
end
|
130
|
+
|
100
131
|
it "should pass any other options through to the link_to method" do
|
101
|
-
self.
|
102
|
-
|
132
|
+
allow(self).to receive_message_chain("uri_state").and_return(:active)
|
133
|
+
|
134
|
+
element = menu_item("Log out", "/users/sign_out", class: "home_link", method: :delete)
|
135
|
+
expect(element).to have_tag(:li, with: {class: "active"}) {
|
136
|
+
with_tag(:a, text: "Log out", with: {
|
137
|
+
href: "/users/sign_out",
|
138
|
+
class: "home_link",
|
139
|
+
rel: "nofollow",
|
140
|
+
"data-method" => "delete"
|
141
|
+
})
|
142
|
+
}
|
103
143
|
end
|
144
|
+
|
104
145
|
it "should pass a block but no name if a block is present" do
|
105
|
-
self.
|
106
|
-
|
146
|
+
allow(self).to receive(:current_page?) { false }
|
147
|
+
|
148
|
+
element = menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }
|
149
|
+
expect(element).to have_tag(:li) {
|
150
|
+
with_tag(:i, with: { class: "icon-home"})
|
151
|
+
with_tag(:a, text: " Home", with: { href: "/"})
|
152
|
+
}
|
107
153
|
end
|
154
|
+
|
108
155
|
it "should work with just a block" do
|
109
|
-
self.
|
110
|
-
|
156
|
+
allow(self).to receive(:current_page?) { false }
|
157
|
+
|
158
|
+
element = menu_item{ content_tag("i", "", :class => "icon-home") + " Home" }
|
159
|
+
expect(element).to have_tag(:li) {
|
160
|
+
with_tag(:i, with: { class: "icon-home"})
|
161
|
+
with_tag(:a, text: " Home", with: { href: "#"})
|
162
|
+
}
|
111
163
|
end
|
164
|
+
|
112
165
|
it "should return the link with class 'active' if on current page with a block" do
|
113
|
-
self.
|
114
|
-
|
166
|
+
allow(self).to receive(:uri_state) { :active }
|
167
|
+
|
168
|
+
element = menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }
|
169
|
+
expect(element).to have_tag(:li, with: {class: "active"}) {
|
170
|
+
with_tag(:i, with: { class: "icon-home"})
|
171
|
+
with_tag(:a, text: " Home", with: { href: "/"})
|
172
|
+
}
|
115
173
|
end
|
116
174
|
end
|
117
175
|
|
118
176
|
describe "drop_down" do
|
119
177
|
it "should do render the proper drop down code" do
|
120
|
-
drop_down "Products" do
|
178
|
+
ele = drop_down "Products" do
|
121
179
|
menu_item "Latest", "/"
|
122
|
-
end
|
180
|
+
end
|
181
|
+
expect(ele).to have_tag(:li, with: {class: 'dropdown'})
|
182
|
+
expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
|
123
183
|
end
|
124
184
|
end
|
125
185
|
|
126
186
|
describe "drop_down_with_submenu" do
|
127
187
|
it "should do render the proper drop down code" do
|
128
|
-
drop_down_with_submenu "Products" do
|
129
|
-
|
130
|
-
|
188
|
+
ele = drop_down_with_submenu "Products" do
|
189
|
+
drop_down_submenu "Latest" do
|
190
|
+
menu_item "Option1", "/"
|
191
|
+
end
|
131
192
|
end
|
132
|
-
|
193
|
+
expect(ele).to have_tag(:li, with: {class: 'dropdown'})
|
194
|
+
expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
|
195
|
+
expect(ele).to have_tag(:ul, with: {class: 'dropdown-menu'})
|
133
196
|
end
|
134
197
|
end
|
135
198
|
|
136
199
|
describe "menu_divider" do
|
137
200
|
it "should render <li class='divider-vertical'></li>" do
|
138
|
-
menu_divider.
|
201
|
+
expect(menu_divider).to match '<li class="divider-vertical"></li>'
|
139
202
|
end
|
140
203
|
end
|
141
204
|
|
142
205
|
describe "menu_text" do
|
143
206
|
it "should render text within p tags with class 'navbar-text" do
|
144
|
-
menu_text("Strapline!").
|
207
|
+
expect(menu_text("Strapline!")).to match("<p class=\"navbar-text\">Strapline!</p>")
|
145
208
|
end
|
146
209
|
|
147
210
|
it "should be able to be pulled right or left" do
|
148
|
-
menu_text("I am being pulled right", :pull => :right).
|
211
|
+
expect(menu_text("I am being pulled right", :pull => :right)).to match("<p class=\"pull-right navbar-text\">I am being pulled right</p>")
|
149
212
|
end
|
150
213
|
|
151
214
|
it "should be able to cope with arbitrary options being passed to the p tag" do
|
152
|
-
menu_text("I am classy!", :class => "classy", :id => "classy_text").
|
215
|
+
expect(menu_text("I am classy!", :class => "classy", :id => "classy_text")).to match("<p class=\"classy navbar-text\" id=\"classy_text\">I am classy!</p>")
|
153
216
|
end
|
154
217
|
|
155
218
|
it "should be able to cope with a block too" do
|
156
|
-
menu_text
|
157
|
-
|
158
|
-
|
219
|
+
ele = menu_text("I have been rendered programmatically!")
|
220
|
+
expect(ele).to have_tag(:p, with: {class: "navbar-text"})
|
221
|
+
expect(ele).to match "I have been rendered programmatically!"
|
159
222
|
end
|
160
223
|
end
|
161
224
|
|
162
225
|
describe "rendering forms ok" do
|
163
226
|
it "should not escape anything unexpectedly" do
|
164
|
-
|
165
|
-
|
166
|
-
|
227
|
+
expect(
|
228
|
+
nav_bar do
|
229
|
+
form_tag "/", :method => 'get' do |f|
|
230
|
+
f.text_field :search, "stub"
|
231
|
+
end
|
167
232
|
end
|
168
|
-
|
233
|
+
).to have_tag(:form)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "default navbar" do
|
238
|
+
it "renders a navbar" do
|
239
|
+
expect(nav_bar { 'foo' }).to have_tag(:nav, with: { class: 'navbar navbar-default', role: 'navigation' }, text: /foo/)
|
169
240
|
end
|
170
241
|
end
|
171
242
|
|
@@ -174,167 +245,132 @@ end
|
|
174
245
|
# HTML output
|
175
246
|
|
176
247
|
BASIC_NAVBAR = <<-HTML
|
177
|
-
<
|
178
|
-
<div class="
|
179
|
-
<div class="container">
|
180
|
-
</div>
|
248
|
+
<nav class="navbar navbar-default" role="navigation">
|
249
|
+
<div class="container">
|
181
250
|
</div>
|
182
|
-
</
|
251
|
+
</nav>
|
183
252
|
HTML
|
184
253
|
|
185
254
|
FIXED_TOP_NAVBAR = <<-HTML
|
186
|
-
<
|
187
|
-
<div class="
|
188
|
-
<div class="container">
|
189
|
-
</div>
|
255
|
+
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
256
|
+
<div class="container">
|
190
257
|
</div>
|
191
|
-
</
|
258
|
+
</nav>
|
192
259
|
HTML
|
193
260
|
|
194
261
|
STATIC_TOP_NAVBAR = <<-HTML
|
195
|
-
<
|
196
|
-
<div class="
|
197
|
-
<div class="container">
|
198
|
-
</div>
|
262
|
+
<nav class="navbar navbar-default navbar-static-top" role="navigation">
|
263
|
+
<div class="container">
|
199
264
|
</div>
|
200
|
-
</
|
265
|
+
</nav>
|
201
266
|
HTML
|
202
267
|
|
203
268
|
FIXED_BOTTOM_NAVBAR = <<-HTML
|
204
|
-
<
|
205
|
-
<div class="
|
206
|
-
<div class="container">
|
207
|
-
</div>
|
269
|
+
<nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
|
270
|
+
<div class="container">
|
208
271
|
</div>
|
209
|
-
</
|
272
|
+
</nav>
|
210
273
|
HTML
|
211
274
|
|
212
275
|
INVERSE_NAVBAR = <<-HTML
|
213
|
-
<
|
214
|
-
<div class="
|
215
|
-
<div class="container">
|
216
|
-
</div>
|
217
|
-
</div>
|
218
|
-
</div>
|
219
|
-
HTML
|
220
|
-
|
221
|
-
BASIC_NAVBAR_FLUID= <<-HTML
|
222
|
-
<div class="navbar">
|
223
|
-
<div class="navbar-inner">
|
224
|
-
<div class="container-fluid">
|
225
|
-
</div>
|
276
|
+
<nav class="navbar navbar-default navbar-inverse" role="navigation">
|
277
|
+
<div class="container">
|
226
278
|
</div>
|
227
|
-
</
|
279
|
+
</nav>
|
228
280
|
HTML
|
229
281
|
|
230
282
|
NAVBAR_WITH_BRAND = <<-HTML
|
231
|
-
<
|
232
|
-
<div class="
|
233
|
-
<
|
234
|
-
|
235
|
-
|
236
|
-
</a>
|
237
|
-
</div>
|
283
|
+
<nav class="navbar navbar-default" role="navigation">
|
284
|
+
<div class="container">
|
285
|
+
<a class="navbar-brand" href="/">
|
286
|
+
Ninety Ten
|
287
|
+
</a>
|
238
288
|
</div>
|
239
|
-
</
|
289
|
+
</nav>
|
240
290
|
HTML
|
241
291
|
|
242
292
|
NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
|
243
|
-
<
|
244
|
-
<div class="
|
245
|
-
<
|
246
|
-
|
247
|
-
|
248
|
-
</a>
|
249
|
-
</div>
|
293
|
+
<nav class="navbar navbar-default" role="navigation">
|
294
|
+
<div class="container">
|
295
|
+
<a class="navbar-brand" href="http://www.ninetyten.com">
|
296
|
+
Ninety Ten
|
297
|
+
</a>
|
250
298
|
</div>
|
251
|
-
</
|
299
|
+
</nav>
|
252
300
|
HTML
|
253
301
|
|
254
302
|
RESPONSIVE_NAVBAR = <<-HTML
|
255
|
-
<
|
256
|
-
<div class="
|
257
|
-
<div class="
|
258
|
-
<
|
303
|
+
<nav class="navbar navbar-default" role="navigation">
|
304
|
+
<div class="container">
|
305
|
+
<div class="navbar-header">
|
306
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
307
|
+
<span class="sr-only">Toggle Navigation</span>
|
259
308
|
<span class="icon-bar"></span>
|
260
309
|
<span class="icon-bar"></span>
|
261
310
|
<span class="icon-bar"></span>
|
262
|
-
</
|
263
|
-
|
264
|
-
|
311
|
+
</button>
|
312
|
+
</div>
|
313
|
+
<div class="navbar-collapse collapse">
|
265
314
|
</div>
|
266
315
|
</div>
|
267
|
-
</
|
316
|
+
</nav>
|
268
317
|
HTML
|
269
318
|
|
270
319
|
RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
|
271
|
-
<
|
272
|
-
<div class="
|
273
|
-
<div class="
|
274
|
-
<
|
320
|
+
<nav class="navbar navbar-default" role="navigation">
|
321
|
+
<div class="container">
|
322
|
+
<div class="navbar-header">
|
323
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
324
|
+
<span class="sr-only">Toggle Navigation</span>
|
275
325
|
<span class="icon-bar"></span>
|
276
326
|
<span class="icon-bar"></span>
|
277
327
|
<span class="icon-bar"></span>
|
278
|
-
</
|
279
|
-
|
280
|
-
|
281
|
-
|
328
|
+
</button>
|
329
|
+
</div>
|
330
|
+
<div class="navbar-collapse collapse">
|
331
|
+
<p>Passing a block</p>
|
282
332
|
</div>
|
283
333
|
</div>
|
284
|
-
</
|
334
|
+
</nav>
|
285
335
|
HTML
|
286
336
|
|
287
337
|
PLAIN_NAVBAR_WITH_ITEM = <<-HTML
|
288
|
-
<
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
</div>
|
301
|
-
</div>
|
338
|
+
<nav class="navbar navbar-default" role="navigation">
|
339
|
+
<div class="container">
|
340
|
+
<ul class="nav navbar-nav">
|
341
|
+
<li>
|
342
|
+
<a href="/">Home</a>
|
343
|
+
</li>
|
344
|
+
<li>
|
345
|
+
<a href="/products">Products</a>
|
346
|
+
</li>
|
347
|
+
</ul>
|
348
|
+
</div>
|
349
|
+
</nav>
|
302
350
|
HTML
|
303
351
|
|
304
352
|
BRANDED_NAVBAR_WITH_ITEM = <<-HTML
|
305
|
-
<
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
</div>
|
318
|
-
</div>
|
353
|
+
<nav class="navbar navbar-default" role="navigation">
|
354
|
+
<div class="container">
|
355
|
+
<a class="navbar-brand" href="/">
|
356
|
+
Something
|
357
|
+
</a>
|
358
|
+
<ul class="nav navbar-nav">
|
359
|
+
<li>
|
360
|
+
<a href="/">Home</a>
|
361
|
+
</li>
|
362
|
+
</ul>
|
363
|
+
</div>
|
364
|
+
</nav>
|
319
365
|
HTML
|
320
366
|
|
321
367
|
DROPDOWN_MENU = <<-HTML
|
322
|
-
<li class="dropdown">
|
323
|
-
<a href="#"
|
324
|
-
class="dropdown-toggle"
|
325
|
-
data-toggle="dropdown">
|
326
|
-
Products
|
327
|
-
<b class="caret"></b>
|
328
|
-
</a>
|
329
|
-
<ul class="dropdown-menu">
|
330
|
-
<li><a href="/">Latest</a></li>
|
331
|
-
</ul>
|
332
|
-
</li>
|
368
|
+
<li class="dropdown"> <a class="dropdown-toggle"data-toggle="dropdown"href="#"> Products <b class="caret"></b> </a> <ul class="dropdown-menu"> <li><a href="/">Latest</a></li> </ul> </li>
|
333
369
|
HTML
|
334
370
|
|
335
371
|
DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
|
336
372
|
<li class="dropdown">
|
337
|
-
<a
|
373
|
+
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Products <b class="caret"></b></a>
|
338
374
|
<ul class="dropdown-menu">
|
339
375
|
<li class="dropdown-submenu">
|
340
376
|
<a href="">Latest</a>
|
@@ -347,16 +383,14 @@ DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
|
|
347
383
|
HTML
|
348
384
|
|
349
385
|
PLAIN_NAVBAR_WITH_FORM = <<-HTML
|
350
|
-
<
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
</div>
|
361
|
-
</div>
|
386
|
+
<nav class=\"navbar navbar-default\"role=\"navigation\">
|
387
|
+
<div class=\"container\">
|
388
|
+
<form accept-charset=\"utf-8\" action=\"/\" method=\"get\">
|
389
|
+
<div style=\"display:none\">
|
390
|
+
<input name=\"utf8\" type=\"hidden\" value=\"✓\"/>
|
391
|
+
</div>
|
392
|
+
<input id=\"search_stub\" name=\"search[stub]\" type=\"text\"/>
|
393
|
+
</form>
|
394
|
+
</div>
|
395
|
+
</nav>
|
362
396
|
HTML
|
@@ -9,37 +9,39 @@ include NavbarHelper
|
|
9
9
|
|
10
10
|
describe NavbarHelper, 'uri_state', type: :helper do
|
11
11
|
before do
|
12
|
-
subject.
|
13
|
-
subject.
|
14
|
-
subject.
|
15
|
-
subject.
|
12
|
+
allow(subject).to receive_message_chain("request.host_with_port").and_return("#{HOST}")
|
13
|
+
allow(subject).to receive_message_chain("request.protocol").and_return("http://")
|
14
|
+
allow(subject).to receive_message_chain("request.url").and_return("#{HOST}/a/b")
|
15
|
+
allow(subject).to receive_message_chain("request.path").and_return('/a/b')
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'must return active state' do
|
19
|
-
subject.uri_state('/a/b')
|
20
|
-
|
19
|
+
expect(subject.uri_state('/a/b'))
|
20
|
+
.to be :active
|
21
|
+
expect(subject.uri_state("#{HOST}/a/b"))
|
22
|
+
.to be :active
|
21
23
|
end
|
22
24
|
|
23
25
|
it 'must not return chosen for non get method' do
|
24
|
-
subject.uri_state('/a/b', :method => 'delete').
|
25
|
-
subject.uri_state("#{HOST}/a/b", :method => 'delete').
|
26
|
-
subject.uri_state('/a/b', "data-method" => 'delete').
|
27
|
-
subject.uri_state("#{HOST}/a/b", "data-method" => 'delete').
|
26
|
+
expect(subject.uri_state('/a/b', :method => 'delete')).to be :inactive
|
27
|
+
expect(subject.uri_state("#{HOST}/a/b", :method => 'delete')).to be :inactive
|
28
|
+
expect(subject.uri_state('/a/b', "data-method" => 'delete')).to be :inactive
|
29
|
+
expect(subject.uri_state("#{HOST}/a/b", "data-method" => 'delete')).to be :inactive
|
28
30
|
end
|
29
31
|
|
30
32
|
it 'must return chosen state' do
|
31
|
-
subject.uri_state('/a').
|
32
|
-
subject.uri_state("#{HOST}/a").
|
33
|
+
expect(subject.uri_state('/a')).to be :chosen
|
34
|
+
expect(subject.uri_state("#{HOST}/a")).to be :chosen
|
33
35
|
end
|
34
36
|
|
35
37
|
it 'must return inactive state' do
|
36
|
-
subject.uri_state('/test').
|
37
|
-
subject.uri_state("#{HOST}/test").
|
38
|
+
expect(subject.uri_state('/test')).to be :inactive
|
39
|
+
expect(subject.uri_state("#{HOST}/test")).to be :inactive
|
38
40
|
end
|
39
41
|
|
40
42
|
it 'must not return chosen for root url' do
|
41
|
-
subject.uri_state('/').
|
42
|
-
subject.uri_state("#{HOST}/").
|
43
|
+
expect(subject.uri_state('/')).to be :inactive
|
44
|
+
expect(subject.uri_state("#{HOST}/")).to be :inactive
|
43
45
|
end
|
44
46
|
|
45
47
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,4 +8,14 @@ require 'rubygems'
|
|
8
8
|
require 'bundler/setup'
|
9
9
|
require 'action_view'
|
10
10
|
require 'active_support'
|
11
|
-
require '
|
11
|
+
require 'active_model'
|
12
|
+
require 'rspec-html-matchers'
|
13
|
+
require 'twitter-bootstrap-rails'
|
14
|
+
require 'abstract_controller'
|
15
|
+
require 'action_controller'
|
16
|
+
require 'mocha/api'
|
17
|
+
require 'pry'
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.include RSpecHtmlMatchers
|
21
|
+
end
|