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.

Files changed (189) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +160 -228
  3. data/Rakefile +4 -6
  4. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  5. data/app/assets/fonts/fontawesome-webfont.svg +279 -38
  6. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  7. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  8. data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
  9. data/app/assets/fonts/glyphicons-halflings-regular.svg +229 -0
  10. data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  11. data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  12. data/app/assets/javascripts/twitter/bootstrap/affix.js +142 -0
  13. data/app/assets/javascripts/twitter/bootstrap/alert.js +92 -0
  14. data/app/assets/javascripts/twitter/bootstrap/button.js +110 -0
  15. data/app/assets/javascripts/twitter/bootstrap/carousel.js +223 -0
  16. data/app/assets/javascripts/twitter/bootstrap/collapse.js +170 -0
  17. data/app/assets/javascripts/twitter/bootstrap/dropdown.js +151 -0
  18. data/app/assets/javascripts/twitter/bootstrap/modal.js +280 -0
  19. data/app/assets/javascripts/twitter/bootstrap/popover.js +113 -0
  20. data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +170 -0
  21. data/app/assets/javascripts/twitter/bootstrap/tab.js +128 -0
  22. data/app/assets/javascripts/twitter/bootstrap/tooltip.js +457 -0
  23. data/app/assets/javascripts/twitter/bootstrap/transition.js +59 -0
  24. data/app/assets/javascripts/twitter/bootstrap.js +12 -13
  25. data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -890
  26. data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +2026 -787
  27. data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +1 -146
  28. data/app/helpers/bootstrap_flash_helper.rb +14 -7
  29. data/app/helpers/form_errors_helper.rb +22 -0
  30. data/app/helpers/glyph_helper.rb +8 -5
  31. data/app/helpers/modal_helper.rb +26 -22
  32. data/app/helpers/navbar_helper.rb +47 -32
  33. data/app/helpers/twitter_breadcrumbs_helper.rb +6 -2
  34. data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +8 -8
  35. data/lib/generators/bootstrap/install/install_generator.rb +3 -2
  36. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +13 -11
  37. data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +5 -0
  38. data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
  39. data/lib/generators/bootstrap/layout/templates/layout.html.erb +27 -48
  40. data/lib/generators/bootstrap/layout/templates/layout.html.haml +19 -34
  41. data/lib/generators/bootstrap/layout/templates/layout.html.slim +13 -30
  42. data/lib/generators/bootstrap/partial/templates/_login.html.erb +2 -3
  43. data/lib/generators/bootstrap/themed/templates/_form.html.erb +30 -10
  44. data/lib/generators/bootstrap/themed/templates/_form.html.haml +10 -8
  45. data/lib/generators/bootstrap/themed/templates/_form.html.slim +11 -9
  46. data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
  47. data/lib/generators/bootstrap/themed/templates/index.html.erb +2 -2
  48. data/lib/generators/bootstrap/themed/templates/index.html.haml +2 -2
  49. data/lib/generators/bootstrap/themed/templates/index.html.slim +4 -5
  50. data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
  51. data/lib/generators/bootstrap/themed/templates/show.html.erb +5 -7
  52. data/lib/generators/bootstrap/themed/templates/show.html.haml +4 -4
  53. data/lib/generators/bootstrap/themed/templates/show.html.slim +6 -7
  54. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +5 -5
  55. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +3 -3
  56. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +4 -4
  57. data/lib/generators/bootstrap/themed/themed_generator.rb +2 -2
  58. data/lib/twitter/bootstrap/rails/breadcrumbs.rb +69 -0
  59. data/lib/twitter/bootstrap/rails/engine.rb +17 -10
  60. data/lib/twitter/bootstrap/rails/version.rb +2 -2
  61. data/spec/lib/breadcrumbs_spec.rb +99 -0
  62. data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +12 -4
  63. data/spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb +128 -0
  64. data/spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb +148 -0
  65. data/spec/lib/twitter_bootstrap_rails/glyph_helper_spec.rb +24 -0
  66. data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +15 -15
  67. data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +207 -173
  68. data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +18 -16
  69. data/spec/spec_helper.rb +11 -1
  70. data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5796 -1
  71. data/vendor/static-source/bootstrap.less +0 -1
  72. data/vendor/static-source/fontawesome.less +0 -1
  73. data/vendor/static-source/sprites.less +1 -1
  74. data/vendor/toolkit/fontawesome/bordered-pulled.less +16 -0
  75. data/vendor/toolkit/fontawesome/core.less +8 -126
  76. data/vendor/toolkit/fontawesome/fixed-width.less +6 -0
  77. data/vendor/toolkit/fontawesome/font-awesome.less +9 -25
  78. data/vendor/toolkit/fontawesome/icons.less +549 -378
  79. data/vendor/toolkit/fontawesome/larger.less +13 -0
  80. data/vendor/toolkit/fontawesome/list.less +19 -0
  81. data/vendor/toolkit/fontawesome/mixins.less +16 -39
  82. data/vendor/toolkit/fontawesome/path.less +5 -5
  83. data/vendor/toolkit/fontawesome/rotated-flipped.less +20 -0
  84. data/vendor/toolkit/fontawesome/spinning.less +29 -0
  85. data/vendor/toolkit/fontawesome/stacked.less +20 -0
  86. data/vendor/toolkit/fontawesome/variables.less +557 -731
  87. data/vendor/toolkit/twitter/bootstrap/alerts.less +47 -58
  88. data/vendor/toolkit/twitter/bootstrap/badges.less +55 -0
  89. data/vendor/toolkit/twitter/bootstrap/bootstrap.less +26 -39
  90. data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +11 -9
  91. data/vendor/toolkit/twitter/bootstrap/button-groups.less +168 -152
  92. data/vendor/toolkit/twitter/bootstrap/buttons.less +101 -170
  93. data/vendor/toolkit/twitter/bootstrap/carousel.less +150 -65
  94. data/vendor/toolkit/twitter/bootstrap/close.less +20 -19
  95. data/vendor/toolkit/twitter/bootstrap/code.less +38 -30
  96. data/vendor/toolkit/twitter/bootstrap/component-animations.less +12 -3
  97. data/vendor/toolkit/twitter/bootstrap/dropdowns.less +115 -148
  98. data/vendor/toolkit/twitter/bootstrap/forms.less +401 -547
  99. data/vendor/toolkit/twitter/bootstrap/glyphicons.less +234 -0
  100. data/vendor/toolkit/twitter/bootstrap/grid.less +74 -11
  101. data/vendor/toolkit/twitter/bootstrap/input-groups.less +166 -0
  102. data/vendor/toolkit/twitter/bootstrap/jumbotron.less +48 -0
  103. data/vendor/toolkit/twitter/bootstrap/labels.less +64 -0
  104. data/vendor/toolkit/twitter/bootstrap/list-group.less +132 -0
  105. data/vendor/toolkit/twitter/bootstrap/media.less +8 -7
  106. data/vendor/toolkit/twitter/bootstrap/mixins/alerts.less +14 -0
  107. data/vendor/toolkit/twitter/bootstrap/mixins/background-variant.less +8 -0
  108. data/vendor/toolkit/twitter/bootstrap/mixins/border-radius.less +18 -0
  109. data/vendor/toolkit/twitter/bootstrap/mixins/buttons.less +52 -0
  110. data/vendor/toolkit/twitter/bootstrap/mixins/center-block.less +7 -0
  111. data/vendor/toolkit/twitter/bootstrap/mixins/clearfix.less +22 -0
  112. data/vendor/toolkit/twitter/bootstrap/mixins/forms.less +85 -0
  113. data/vendor/toolkit/twitter/bootstrap/mixins/gradients.less +59 -0
  114. data/vendor/toolkit/twitter/bootstrap/mixins/grid-framework.less +91 -0
  115. data/vendor/toolkit/twitter/bootstrap/mixins/grid.less +122 -0
  116. data/vendor/toolkit/twitter/bootstrap/mixins/hide-text.less +21 -0
  117. data/vendor/toolkit/twitter/bootstrap/mixins/image.less +33 -0
  118. data/vendor/toolkit/twitter/bootstrap/mixins/labels.less +12 -0
  119. data/vendor/toolkit/twitter/bootstrap/mixins/list-group.less +29 -0
  120. data/vendor/toolkit/twitter/bootstrap/mixins/nav-divider.less +10 -0
  121. data/vendor/toolkit/twitter/bootstrap/mixins/nav-vertical-align.less +9 -0
  122. data/vendor/toolkit/twitter/bootstrap/mixins/opacity.less +8 -0
  123. data/vendor/toolkit/twitter/bootstrap/mixins/pagination.less +23 -0
  124. data/vendor/toolkit/twitter/bootstrap/mixins/panels.less +24 -0
  125. data/vendor/toolkit/twitter/bootstrap/mixins/progress-bar.less +10 -0
  126. data/vendor/toolkit/twitter/bootstrap/mixins/reset-filter.less +8 -0
  127. data/vendor/toolkit/twitter/bootstrap/mixins/resize.less +6 -0
  128. data/vendor/toolkit/twitter/bootstrap/mixins/responsive-visibility.less +15 -0
  129. data/vendor/toolkit/twitter/bootstrap/mixins/size.less +10 -0
  130. data/vendor/toolkit/twitter/bootstrap/mixins/tab-focus.less +9 -0
  131. data/vendor/toolkit/twitter/bootstrap/mixins/table-row.less +28 -0
  132. data/vendor/toolkit/twitter/bootstrap/mixins/text-emphasis.less +8 -0
  133. data/vendor/toolkit/twitter/bootstrap/mixins/text-overflow.less +8 -0
  134. data/vendor/toolkit/twitter/bootstrap/mixins/vendor-prefixes.less +224 -0
  135. data/vendor/toolkit/twitter/bootstrap/mixins.less +36 -699
  136. data/vendor/toolkit/twitter/bootstrap/modals.less +109 -54
  137. data/vendor/toolkit/twitter/bootstrap/navbar.less +542 -384
  138. data/vendor/toolkit/twitter/bootstrap/navs.less +192 -359
  139. data/vendor/toolkit/twitter/bootstrap/normalize.less +425 -0
  140. data/vendor/toolkit/twitter/bootstrap/pager.less +46 -34
  141. data/vendor/toolkit/twitter/bootstrap/pagination.less +70 -105
  142. data/vendor/toolkit/twitter/bootstrap/panels.less +248 -0
  143. data/vendor/toolkit/twitter/bootstrap/popovers.less +61 -61
  144. data/vendor/toolkit/twitter/bootstrap/print.less +101 -0
  145. data/vendor/toolkit/twitter/bootstrap/progress-bars.less +51 -73
  146. data/vendor/toolkit/twitter/bootstrap/responsive-embed.less +34 -0
  147. data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +177 -42
  148. data/vendor/toolkit/twitter/bootstrap/scaffolding.less +120 -23
  149. data/vendor/toolkit/twitter/bootstrap/tables.less +171 -182
  150. data/vendor/toolkit/twitter/bootstrap/theme.less +260 -0
  151. data/vendor/toolkit/twitter/bootstrap/thumbnails.less +26 -43
  152. data/vendor/toolkit/twitter/bootstrap/tooltip.less +49 -24
  153. data/vendor/toolkit/twitter/bootstrap/type.less +208 -147
  154. data/vendor/toolkit/twitter/bootstrap/utilities.less +33 -7
  155. data/vendor/toolkit/twitter/bootstrap/variables.less +761 -215
  156. data/vendor/toolkit/twitter/bootstrap/wells.less +7 -7
  157. metadata +156 -130
  158. data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
  159. data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
  160. data/app/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +0 -117
  161. data/app/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +0 -99
  162. data/app/assets/javascripts/twitter/bootstrap/bootstrap-button.js +0 -105
  163. data/app/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +0 -207
  164. data/app/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +0 -167
  165. data/app/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +0 -169
  166. data/app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +0 -247
  167. data/app/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +0 -114
  168. data/app/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +0 -162
  169. data/app/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +0 -144
  170. data/app/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +0 -361
  171. data/app/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +0 -60
  172. data/app/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +0 -335
  173. data/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +0 -42
  174. data/test/lib/breadcrumbs_test.rb +0 -75
  175. data/test/test_helper.rb +0 -11
  176. data/vendor/toolkit/fontawesome/bootstrap.less +0 -84
  177. data/vendor/toolkit/fontawesome/extras.less +0 -93
  178. data/vendor/toolkit/fontawesome/font-awesome-ie7.less +0 -1953
  179. data/vendor/toolkit/twitter/bootstrap/accordion.less +0 -34
  180. data/vendor/toolkit/twitter/bootstrap/hero-unit.less +0 -25
  181. data/vendor/toolkit/twitter/bootstrap/labels-badges.less +0 -84
  182. data/vendor/toolkit/twitter/bootstrap/layouts.less +0 -16
  183. data/vendor/toolkit/twitter/bootstrap/reset.less +0 -216
  184. data/vendor/toolkit/twitter/bootstrap/responsive-1200px-min.less +0 -28
  185. data/vendor/toolkit/twitter/bootstrap/responsive-767px-max.less +0 -193
  186. data/vendor/toolkit/twitter/bootstrap/responsive-768px-979px.less +0 -19
  187. data/vendor/toolkit/twitter/bootstrap/responsive-navbar.less +0 -189
  188. data/vendor/toolkit/twitter/bootstrap/responsive.less +0 -48
  189. 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.stub!("uri_state").and_return(:inactive)
15
- self.stub!("root_url").and_return("/")
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.should eql(BASIC_NAVBAR.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.should eql(FIXED_TOP_NAVBAR.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.should eql(STATIC_TOP_NAVBAR.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.should eql(FIXED_BOTTOM_NAVBAR.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.should eql(INVERSE_NAVBAR.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.should eql(NAVBAR_WITH_BRAND.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.should eql(NAVBAR_WITH_BRAND_AND_LINK.gsub(/\s/, '').downcase)
44
- end
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.should eql(RESPONSIVE_NAVBAR.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.gsub(/\s/, '').downcase.should eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/, '').downcase)
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.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
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.gsub(/\s/, '').downcase.should eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
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.should eql '<ul class="nav "><li><a href="/">Home</a></li><li><a href="/products">Products</a></li></ul>'
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 .pull-left when passed the {:pull => :left} option" do
85
- menu_group(:pull => :left) do
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.should eql('<ul class="nav pull-left"><li><a href="/">Home</a></li></ul>')
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.stub!("current_page?").and_return(false)
94
- menu_item("Home", "/").should eql('<li><a href="/">Home</a></li>')
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.stub!("uri_state").and_return(:active)
98
- menu_item("Home", "/").should eql('<li class="active"><a href="/">Home</a></li>')
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.stub!("uri_state").and_return(:active)
102
- menu_item("Log out", "/users/sign_out", :class => "home_link", :method => :delete).should eql('<li class="active"><a href="/users/sign_out" class="home_link" data-method="delete" rel="nofollow">Log out</a></li>')
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.stub!("current_page?").and_return(false)
106
- menu_item("/"){content_tag("i", "", :class => "icon-home") + " Home"}.should eql('<li><a href="/"><i class="icon-home"></i> Home</a></li>')
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.stub!("current_page?").and_return(false)
110
- menu_item{ content_tag("i", "", :class => "icon-home") + " Home" }.should eql('<li><a href="#"><i class="icon-home"></i> Home</a></li>')
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.stub!("uri_state").and_return(:active)
114
- menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }.should eql('<li class="active"><a href="/"><i class="icon-home"></i> Home</a></li>')
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.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU.gsub(/\s/, '').downcase)
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
- drop_down_submenu "Latest" do
130
- menu_item "Option1", "/"
188
+ ele = drop_down_with_submenu "Products" do
189
+ drop_down_submenu "Latest" do
190
+ menu_item "Option1", "/"
191
+ end
131
192
  end
132
- end.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU_WITH_SUBMENU.gsub(/\s/, '').downcase)
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.should eql '<li class="divider-vertical"></li>'
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!").should eql("<p class=\"navbar-text\">Strapline!</p>")
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).should eql("<p class=\"pull-right navbar-text\">I am being pulled right</p>")
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").should eql("<p class=\"classy navbar-text\" id=\"classy_text\">I am classy!</p>")
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 do
157
- "I have been rendered programmatically!"
158
- end.should eql("<p class=\"navbar-text\">I have been rendered programmatically!</p>")
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
- nav_bar do
165
- form_tag "/", :method => 'get' do |f|
166
- f.text_field :search, "stub"
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
- end.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_FORM.gsub(/\s/, '').downcase)
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
- <div class="navbar">
178
- <div class="navbar-inner">
179
- <div class="container">
180
- </div>
248
+ <nav class="navbar navbar-default" role="navigation">
249
+ <div class="container">
181
250
  </div>
182
- </div>
251
+ </nav>
183
252
  HTML
184
253
 
185
254
  FIXED_TOP_NAVBAR = <<-HTML
186
- <div class="navbar navbar-fixed-top">
187
- <div class="navbar-inner">
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
- </div>
258
+ </nav>
192
259
  HTML
193
260
 
194
261
  STATIC_TOP_NAVBAR = <<-HTML
195
- <div class="navbar navbar-static-top">
196
- <div class="navbar-inner">
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
- </div>
265
+ </nav>
201
266
  HTML
202
267
 
203
268
  FIXED_BOTTOM_NAVBAR = <<-HTML
204
- <div class="navbar navbar-fixed-bottom">
205
- <div class="navbar-inner">
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
- </div>
272
+ </nav>
210
273
  HTML
211
274
 
212
275
  INVERSE_NAVBAR = <<-HTML
213
- <div class="navbar navbar-inverse">
214
- <div class="navbar-inner">
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
- </div>
279
+ </nav>
228
280
  HTML
229
281
 
230
282
  NAVBAR_WITH_BRAND = <<-HTML
231
- <div class="navbar">
232
- <div class="navbar-inner">
233
- <div class="container">
234
- <a href="/" class="brand">
235
- Ninety Ten
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
- </div>
289
+ </nav>
240
290
  HTML
241
291
 
242
292
  NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
243
- <div class="navbar">
244
- <div class="navbar-inner">
245
- <div class="container">
246
- <a href="http://www.ninetyten.com" class="brand">
247
- Ninety Ten
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
- </div>
299
+ </nav>
252
300
  HTML
253
301
 
254
302
  RESPONSIVE_NAVBAR = <<-HTML
255
- <div class="navbar">
256
- <div class="navbar-inner">
257
- <div class="container">
258
- <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
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
- </a>
263
- <div class="nav-collapse">
264
- </div>
311
+ </button>
312
+ </div>
313
+ <div class="navbar-collapse collapse">
265
314
  </div>
266
315
  </div>
267
- </div>
316
+ </nav>
268
317
  HTML
269
318
 
270
319
  RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
271
- <div class="navbar">
272
- <div class="navbar-inner">
273
- <div class="container">
274
- <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
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
- </a>
279
- <div class="nav-collapse">
280
- <p>Passing a block</p>
281
- </div>
328
+ </button>
329
+ </div>
330
+ <div class="navbar-collapse collapse">
331
+ <p>Passing a block</p>
282
332
  </div>
283
333
  </div>
284
- </div>
334
+ </nav>
285
335
  HTML
286
336
 
287
337
  PLAIN_NAVBAR_WITH_ITEM = <<-HTML
288
- <div class="navbar">
289
- <div class="navbar-inner">
290
- <div class="container">
291
- <ul class="nav">
292
- <li>
293
- <a href="/">Home</a>
294
- </li>
295
- <li>
296
- <a href="/products">Products</a>
297
- </li>
298
- </ul>
299
- </div>
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
- <div class="navbar">
306
- <div class="navbar-inner">
307
- <div class="container">
308
- <a href="/" class="brand">
309
- Something
310
- </a>
311
- <ul class="nav">
312
- <li>
313
- <a href="/">Home</a>
314
- </li>
315
- </ul>
316
- </div>
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 href="#" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></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
- <div class="navbar">
351
- <div class="navbar-inner">
352
- <div class="container">
353
- <form accept-charset="utf-8" action="/" method="get">
354
- <div style="margin:0;padding:0;display:inline">
355
- <input name="utf8" type="hidden" value="&#x2713;"/>
356
- </div>
357
- <input id="search_stub" name="search[stub]" size="30" type="text"/>
358
- </form>
359
- </div>
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=\"&#x2713;\"/>
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.stub_chain("request.host_with_port").and_return("#{HOST}")
13
- subject.stub_chain("request.protocol").and_return("http://")
14
- subject.stub_chain("request.url").and_return("#{HOST}/a/b")
15
- subject.stub_chain("request.path").and_return('/a/b')
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').should == :active
20
- subject.uri_state("#{HOST}/a/b").should == :active
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').should == :inactive
25
- subject.uri_state("#{HOST}/a/b", :method => 'delete').should == :inactive
26
- subject.uri_state('/a/b', "data-method" => 'delete').should == :inactive
27
- subject.uri_state("#{HOST}/a/b", "data-method" => 'delete').should == :inactive
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').should == :chosen
32
- subject.uri_state("#{HOST}/a").should == :chosen
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').should == :inactive
37
- subject.uri_state("#{HOST}/test").should == :inactive
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('/').should == :inactive
42
- subject.uri_state("#{HOST}/").should == :inactive
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 'twitter-bootstrap-rails'
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