twitter-bootstrap-rails 2.2.3 → 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 +460 -185
- data/Rakefile +7 -1
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +640 -0
- 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.js +12 -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/{vendor → app}/assets/javascripts/twitter/bootstrap_ujs.js +0 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +2026 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +1 -0
- data/app/helpers/badge_label_helper.rb +16 -0
- data/app/helpers/bootstrap_flash_helper.rb +20 -6
- data/app/helpers/form_errors_helper.rb +22 -0
- data/app/helpers/glyph_helper.rb +13 -5
- data/app/helpers/modal_helper.rb +37 -20
- data/app/helpers/navbar_helper.rb +209 -0
- data/app/helpers/twitter_breadcrumbs_helper.rb +11 -2
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +9 -9
- data/lib/generators/bootstrap/install/install_generator.rb +13 -8
- data/lib/generators/bootstrap/install/templates/bootstrap.coffee +2 -3
- data/lib/generators/bootstrap/install/templates/bootstrap.js +2 -3
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +14 -13
- data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +11 -5
- data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +34 -58
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +25 -44
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +20 -39
- 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.erb +1 -2
- data/lib/generators/bootstrap/themed/templates/edit.html.haml +1 -1
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +2 -2
- data/lib/generators/bootstrap/themed/templates/index.html.erb +3 -3
- data/lib/generators/bootstrap/themed/templates/index.html.haml +3 -3
- data/lib/generators/bootstrap/themed/templates/index.html.slim +5 -6
- data/lib/generators/bootstrap/themed/templates/new.html.erb +1 -2
- data/lib/generators/bootstrap/themed/templates/new.html.haml +1 -1
- data/lib/generators/bootstrap/themed/templates/new.html.slim +2 -2
- data/lib/generators/bootstrap/themed/templates/show.html.erb +6 -8
- data/lib/generators/bootstrap/themed/templates/show.html.haml +5 -5
- data/lib/generators/bootstrap/themed/templates/show.html.slim +7 -8
- 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 +4 -4
- data/lib/twitter-bootstrap-rails.rb +4 -4
- data/lib/twitter/bootstrap/rails/breadcrumbs.rb +69 -0
- data/lib/twitter/bootstrap/rails/engine.rb +17 -7
- data/lib/twitter/bootstrap/rails/version.rb +1 -1
- data/spec/lib/breadcrumbs_spec.rb +99 -0
- data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +30 -0
- 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 +62 -0
- data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +396 -0
- data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +49 -0
- data/spec/spec_helper.rb +21 -0
- data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5990 -195
- data/vendor/static-source/bootstrap.less +0 -1
- data/vendor/static-source/fontawesome.less +7 -6
- data/vendor/static-source/sprites.less +3 -3
- data/vendor/toolkit/fontawesome/bordered-pulled.less +16 -0
- data/vendor/toolkit/fontawesome/core.less +11 -0
- data/vendor/toolkit/fontawesome/fixed-width.less +6 -0
- data/vendor/toolkit/fontawesome/font-awesome.less +17 -0
- data/vendor/toolkit/fontawesome/icons.less +552 -0
- data/vendor/toolkit/fontawesome/larger.less +13 -0
- data/vendor/toolkit/fontawesome/list.less +19 -0
- data/vendor/toolkit/fontawesome/mixins.less +25 -0
- data/vendor/toolkit/fontawesome/path.less +14 -0
- 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 +561 -0
- 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 +124 -146
- 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.less +36 -699
- 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/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 +199 -92
- data/lib/generators/bootstrap/partial/templates/_navbar.html.erb +0 -13
- 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 -8
- data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/twitter/bootstrap.js +0 -13
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +0 -117
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +0 -99
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +0 -105
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +0 -207
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +0 -167
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +0 -165
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +0 -247
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +0 -114
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +0 -162
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +0 -144
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +0 -353
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +0 -60
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +0 -335
- data/vendor/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +0 -531
- data/vendor/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +0 -146
- data/vendor/toolkit/fontawesome-ie7.less +0 -350
- data/vendor/toolkit/fontawesome.less +0 -532
- 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
@@ -0,0 +1,396 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#Credit for this goes to https://github.com/julescopeland/Rails-Bootstrap-Navbar
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'action_view'
|
5
|
+
require 'active_support'
|
6
|
+
require_relative '../../../app/helpers/navbar_helper'
|
7
|
+
|
8
|
+
include ActionView::Helpers
|
9
|
+
include ActionView::Context
|
10
|
+
include NavbarHelper
|
11
|
+
|
12
|
+
describe NavbarHelper, :type => :helper do
|
13
|
+
before do
|
14
|
+
allow(self).to receive(:uri_state) { :inactive }
|
15
|
+
allow(self).to receive(:root_url) { '/' }
|
16
|
+
end
|
17
|
+
describe "nav_bar" do
|
18
|
+
it "should return a basic bootstrap navbar" do
|
19
|
+
expect(nav_bar.gsub(/\s/, '').downcase)
|
20
|
+
.to eql(BASIC_NAVBAR.gsub(/\s/, '').downcase)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set the fixed position to top" do
|
24
|
+
expect(nav_bar(:fixed => :top).gsub(/\s/, '').downcase)
|
25
|
+
.to eql(FIXED_TOP_NAVBAR.gsub(/\s/, '').downcase)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set the static position to top" do
|
29
|
+
expect(nav_bar(:static => :top).gsub(/\s/, '').downcase)
|
30
|
+
.to eql(STATIC_TOP_NAVBAR.gsub(/\s/, '').downcase)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set the fixed position to bottom" do
|
34
|
+
expect(nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase)
|
35
|
+
.to eql(FIXED_BOTTOM_NAVBAR.gsub(/\s/, '').downcase)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set the style to inverse" do
|
39
|
+
expect(nav_bar(:inverse => true).gsub(/\s/, '').downcase)
|
40
|
+
.to eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should add the brand name and link it to the home page" do
|
44
|
+
expect(nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase)
|
45
|
+
.to eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be able to set the brand link url" do
|
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)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should add the buttons etc for a responsive layout with no block passed" do
|
54
|
+
expect(nav_bar(:responsive => true).gsub(/\s/, '').downcase).to eql(RESPONSIVE_NAVBAR.gsub(/\s/, '').downcase)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should add the buttons etc for a responsive layout with block passed" do
|
58
|
+
ele = nav_bar(:responsive => true) do
|
59
|
+
"<p>Passing a block</p>".html_safe
|
60
|
+
end
|
61
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/, '').downcase)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should render contained items" do
|
65
|
+
ele = nav_bar do
|
66
|
+
menu_group do
|
67
|
+
menu_item("Home", "/") + menu_item("Products", "/products")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should still render the brand name even with other options turned on" do
|
74
|
+
ele = nav_bar(:brand => "Something") do
|
75
|
+
menu_group do
|
76
|
+
menu_item "Home", "/"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
expect(ele.gsub(/\s/, '').downcase).to eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "menu_group" do
|
84
|
+
it "should return a ul with the class 'nav'" do
|
85
|
+
element = menu_group do
|
86
|
+
menu_item("Home", "/") + menu_item("Products", "/products")
|
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
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should return a ul with class .navbar-left when passed the {pull: :left} option" do
|
100
|
+
element = menu_group(pull: :left) do
|
101
|
+
menu_item("Home", "/")
|
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
|
+
}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "menu_item" do
|
113
|
+
it "should return a link within an li tag" do
|
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
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should return the link with class 'active' if on current page" do
|
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
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should pass any other options through to the link_to method" do
|
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
|
+
}
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should pass a block but no name if a block is present" do
|
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
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should work with just a block" do
|
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
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should return the link with class 'active' if on current page with a block" do
|
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
|
+
}
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "drop_down" do
|
177
|
+
it "should do render the proper drop down code" do
|
178
|
+
ele = drop_down "Products" do
|
179
|
+
menu_item "Latest", "/"
|
180
|
+
end
|
181
|
+
expect(ele).to have_tag(:li, with: {class: 'dropdown'})
|
182
|
+
expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "drop_down_with_submenu" do
|
187
|
+
it "should do render the proper drop down code" do
|
188
|
+
ele = drop_down_with_submenu "Products" do
|
189
|
+
drop_down_submenu "Latest" do
|
190
|
+
menu_item "Option1", "/"
|
191
|
+
end
|
192
|
+
end
|
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'})
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "menu_divider" do
|
200
|
+
it "should render <li class='divider-vertical'></li>" do
|
201
|
+
expect(menu_divider).to match '<li class="divider-vertical"></li>'
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "menu_text" do
|
206
|
+
it "should render text within p tags with class 'navbar-text" do
|
207
|
+
expect(menu_text("Strapline!")).to match("<p class=\"navbar-text\">Strapline!</p>")
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should be able to be pulled right or left" do
|
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>")
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should be able to cope with arbitrary options being passed to the p tag" do
|
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>")
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should be able to cope with a block too" do
|
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!"
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe "rendering forms ok" do
|
226
|
+
it "should not escape anything unexpectedly" do
|
227
|
+
expect(
|
228
|
+
nav_bar do
|
229
|
+
form_tag "/", :method => 'get' do |f|
|
230
|
+
f.text_field :search, "stub"
|
231
|
+
end
|
232
|
+
end
|
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/)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
# HTML output
|
246
|
+
|
247
|
+
BASIC_NAVBAR = <<-HTML
|
248
|
+
<nav class="navbar navbar-default" role="navigation">
|
249
|
+
<div class="container">
|
250
|
+
</div>
|
251
|
+
</nav>
|
252
|
+
HTML
|
253
|
+
|
254
|
+
FIXED_TOP_NAVBAR = <<-HTML
|
255
|
+
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
256
|
+
<div class="container">
|
257
|
+
</div>
|
258
|
+
</nav>
|
259
|
+
HTML
|
260
|
+
|
261
|
+
STATIC_TOP_NAVBAR = <<-HTML
|
262
|
+
<nav class="navbar navbar-default navbar-static-top" role="navigation">
|
263
|
+
<div class="container">
|
264
|
+
</div>
|
265
|
+
</nav>
|
266
|
+
HTML
|
267
|
+
|
268
|
+
FIXED_BOTTOM_NAVBAR = <<-HTML
|
269
|
+
<nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
|
270
|
+
<div class="container">
|
271
|
+
</div>
|
272
|
+
</nav>
|
273
|
+
HTML
|
274
|
+
|
275
|
+
INVERSE_NAVBAR = <<-HTML
|
276
|
+
<nav class="navbar navbar-default navbar-inverse" role="navigation">
|
277
|
+
<div class="container">
|
278
|
+
</div>
|
279
|
+
</nav>
|
280
|
+
HTML
|
281
|
+
|
282
|
+
NAVBAR_WITH_BRAND = <<-HTML
|
283
|
+
<nav class="navbar navbar-default" role="navigation">
|
284
|
+
<div class="container">
|
285
|
+
<a class="navbar-brand" href="/">
|
286
|
+
Ninety Ten
|
287
|
+
</a>
|
288
|
+
</div>
|
289
|
+
</nav>
|
290
|
+
HTML
|
291
|
+
|
292
|
+
NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
|
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>
|
298
|
+
</div>
|
299
|
+
</nav>
|
300
|
+
HTML
|
301
|
+
|
302
|
+
RESPONSIVE_NAVBAR = <<-HTML
|
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>
|
308
|
+
<span class="icon-bar"></span>
|
309
|
+
<span class="icon-bar"></span>
|
310
|
+
<span class="icon-bar"></span>
|
311
|
+
</button>
|
312
|
+
</div>
|
313
|
+
<div class="navbar-collapse collapse">
|
314
|
+
</div>
|
315
|
+
</div>
|
316
|
+
</nav>
|
317
|
+
HTML
|
318
|
+
|
319
|
+
RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
|
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>
|
325
|
+
<span class="icon-bar"></span>
|
326
|
+
<span class="icon-bar"></span>
|
327
|
+
<span class="icon-bar"></span>
|
328
|
+
</button>
|
329
|
+
</div>
|
330
|
+
<div class="navbar-collapse collapse">
|
331
|
+
<p>Passing a block</p>
|
332
|
+
</div>
|
333
|
+
</div>
|
334
|
+
</nav>
|
335
|
+
HTML
|
336
|
+
|
337
|
+
PLAIN_NAVBAR_WITH_ITEM = <<-HTML
|
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>
|
350
|
+
HTML
|
351
|
+
|
352
|
+
BRANDED_NAVBAR_WITH_ITEM = <<-HTML
|
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>
|
365
|
+
HTML
|
366
|
+
|
367
|
+
DROPDOWN_MENU = <<-HTML
|
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>
|
369
|
+
HTML
|
370
|
+
|
371
|
+
DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
|
372
|
+
<li class="dropdown">
|
373
|
+
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Products <b class="caret"></b></a>
|
374
|
+
<ul class="dropdown-menu">
|
375
|
+
<li class="dropdown-submenu">
|
376
|
+
<a href="">Latest</a>
|
377
|
+
<ul class="dropdown-menu">
|
378
|
+
<li><a href="/">Option1</a></li>
|
379
|
+
</ul>
|
380
|
+
</li>
|
381
|
+
</ul>
|
382
|
+
</li>
|
383
|
+
HTML
|
384
|
+
|
385
|
+
PLAIN_NAVBAR_WITH_FORM = <<-HTML
|
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>
|
396
|
+
HTML
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'action_view'
|
3
|
+
require 'active_support'
|
4
|
+
require_relative '../../../app/helpers/navbar_helper'
|
5
|
+
|
6
|
+
include ActionView::Helpers
|
7
|
+
include ActionView::Context
|
8
|
+
include NavbarHelper
|
9
|
+
|
10
|
+
describe NavbarHelper, 'uri_state', type: :helper do
|
11
|
+
before do
|
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
|
+
end
|
17
|
+
|
18
|
+
it 'must return active state' do
|
19
|
+
expect(subject.uri_state('/a/b'))
|
20
|
+
.to be :active
|
21
|
+
expect(subject.uri_state("#{HOST}/a/b"))
|
22
|
+
.to be :active
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'must not return chosen for non get method' do
|
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
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'must return chosen state' do
|
33
|
+
expect(subject.uri_state('/a')).to be :chosen
|
34
|
+
expect(subject.uri_state("#{HOST}/a")).to be :chosen
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'must return inactive state' do
|
38
|
+
expect(subject.uri_state('/test')).to be :inactive
|
39
|
+
expect(subject.uri_state("#{HOST}/test")).to be :inactive
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'must not return chosen for root url' do
|
43
|
+
expect(subject.uri_state('/')).to be :inactive
|
44
|
+
expect(subject.uri_state("#{HOST}/")).to be :inactive
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
HOST = "http://example.com:80"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'rubygems'
|
8
|
+
require 'bundler/setup'
|
9
|
+
require 'action_view'
|
10
|
+
require 'active_support'
|
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
|