twitter-bootstrap-rails 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/README.md +72 -1
  4. data/app/helpers/badge_label_helper.rb +5 -6
  5. data/app/helpers/bootstrap_flash_helper.rb +10 -5
  6. data/app/helpers/flash_block_helper.rb +6 -4
  7. data/app/helpers/form_errors_helper.rb +3 -2
  8. data/app/helpers/modal_helper.rb +13 -13
  9. data/app/helpers/navbar_helper.rb +54 -47
  10. data/app/helpers/twitter_breadcrumbs_helper.rb +2 -2
  11. data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +11 -11
  12. data/lib/generators/bootstrap/agent/agent_generator.rb +81 -0
  13. data/lib/generators/bootstrap/agent/templates/guide.md.erb +61 -0
  14. data/lib/generators/bootstrap/doctor/doctor_generator.rb +39 -0
  15. data/lib/generators/bootstrap/partial/templates/_login.html.erb +11 -15
  16. data/lib/generators/bootstrap/snippets/snippet_base.rb +23 -4
  17. data/lib/generators/bootstrap/themed/templates/_form.html.haml +7 -9
  18. data/lib/generators/bootstrap/themed/templates/_form.html.slim +8 -10
  19. data/lib/generators/bootstrap/themed/templates/edit.html.erb +1 -1
  20. data/lib/generators/bootstrap/themed/templates/edit.html.haml +1 -1
  21. data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
  22. data/lib/generators/bootstrap/themed/templates/index.html.haml +4 -4
  23. data/lib/generators/bootstrap/themed/templates/index.html.slim +4 -4
  24. data/lib/generators/bootstrap/themed/templates/new.html.erb +1 -1
  25. data/lib/generators/bootstrap/themed/templates/new.html.haml +1 -1
  26. data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
  27. data/lib/generators/bootstrap/themed/templates/show.html.erb +1 -1
  28. data/lib/generators/bootstrap/themed/templates/show.html.haml +3 -3
  29. data/lib/generators/bootstrap/themed/templates/show.html.slim +3 -3
  30. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +1 -1
  31. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +2 -2
  32. data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +2 -2
  33. data/lib/twitter/bootstrap/rails/doctor.rb +207 -0
  34. data/lib/twitter/bootstrap/rails/legacy_markup.rb +119 -0
  35. data/lib/twitter/bootstrap/rails/version.rb +1 -1
  36. data/spec/lib/breadcrumbs_spec.rb +8 -2
  37. data/spec/lib/generators/agent_generator_spec.rb +111 -0
  38. data/spec/lib/generators/doctor_generator_spec.rb +216 -0
  39. data/spec/lib/generators/snippet_generators_spec.rb +23 -0
  40. data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +7 -3
  41. data/spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb +23 -45
  42. data/spec/lib/twitter_bootstrap_rails/breadcrumbs_view_spec.rb +35 -0
  43. data/spec/lib/twitter_bootstrap_rails/flash_block_helper_spec.rb +26 -0
  44. data/spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb +2 -2
  45. data/spec/lib/twitter_bootstrap_rails/legacy_markup_spec.rb +74 -0
  46. data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +21 -8
  47. data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +94 -92
  48. data/spec/spec_helper.rb +0 -1
  49. data/spec/support/generator_spec_helper.rb +2 -0
  50. metadata +21 -3
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require_relative '../../../app/helpers/twitter_breadcrumbs_helper'
3
+
4
+ describe "twitter-bootstrap/_breadcrumbs" do
5
+ let(:crumbs) do
6
+ [{ :name => "Home", :url => "/", :options => {} },
7
+ { :name => "Tasks", :url => "/tasks", :options => {} }]
8
+ end
9
+
10
+ let(:view) do
11
+ views = File.expand_path("../../../app/views", __dir__)
12
+ ActionView::Base.with_empty_template_cache
13
+ .with_view_paths([views], { "__bs_breadcrumbs" => crumbs })
14
+ .tap { |v| v.extend(TwitterBreadcrumbsHelper) }
15
+ end
16
+
17
+ it "renders Bootstrap 5 breadcrumb markup" do
18
+ html = view.render_bootstrap_breadcrumbs
19
+
20
+ expect(html).to have_tag("nav", :with => { "aria-label" => "breadcrumb" }) do
21
+ with_tag("ol.breadcrumb li.breadcrumb-item a", :text => "Home", :with => { :href => "/" })
22
+ end
23
+ end
24
+
25
+ it "marks the last crumb as the current page" do
26
+ expect(view.render_bootstrap_breadcrumbs)
27
+ .to have_tag("li.breadcrumb-item.active", :text => /Tasks/, :with => { "aria-current" => "page" })
28
+ end
29
+
30
+ it "sets the divider through Bootstrap's CSS variable" do
31
+ nav = Nokogiri::HTML.fragment(view.render_bootstrap_breadcrumbs(">")).at_css("nav")
32
+
33
+ expect(nav["style"]).to eq("--bs-breadcrumb-divider: '>';")
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require_relative '../../../app/helpers/flash_block_helper'
4
+
5
+ include ActionView::Helpers
6
+ include ActionView::Context
7
+ include FlashBlockHelper
8
+
9
+ describe FlashBlockHelper, :type => :helper do
10
+ it "maps Rails flash keys onto Bootstrap's alert colours" do
11
+ allow(self).to receive(:flash) { { :notice => "Saved", :alert => "Nope" } }
12
+
13
+ expect(flash_block).to have_tag("div.alert.alert-success.alert-dismissible.fade.show", :text => "Saved")
14
+ expect(flash_block).to have_tag("div.alert.alert-danger", :text => "Nope")
15
+ end
16
+
17
+ it "renders a Bootstrap 5 close button" do
18
+ expect(flash_container(:info, "Hi")).to have_tag(:button, :with => {
19
+ :class => "btn-close", :type => "button", "data-bs-dismiss" => "alert", "aria-label" => "Close"
20
+ })
21
+ end
22
+
23
+ it "escapes unsafe messages" do
24
+ expect(flash_container(:info, "<script>alert(1)</script>")).not_to include("<script>")
25
+ end
26
+ end
@@ -27,8 +27,8 @@ describe FormErrorsHelper, :type => :helper do
27
27
  allow(self).to receive_messages(:protect_against_forgery? => false)
28
28
  allow(self).to receive_messages(:polymorphic_path => '')
29
29
 
30
- @default_class = 'help-block'
31
- @default_error_class = 'has-error'
30
+ @default_class = 'invalid-feedback'
31
+ @default_error_class = 'has-validation'
32
32
  end
33
33
 
34
34
 
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'twitter/bootstrap/rails/legacy_markup'
3
+
4
+ describe Twitter::Bootstrap::Rails::LegacyMarkup do
5
+ def found(text, extension = ".erb")
6
+ described_class.scan(text, extension).map { |f| f[:found] }
7
+ end
8
+
9
+ it "reports the line and the replacement" do
10
+ finding = described_class.scan(%{<p>ok</p>\n<a class="btn btn-default">x</a>}, ".erb").first
11
+
12
+ expect(finding).to include(:line => 2, :found => "btn-default", :replacement => "btn-secondary")
13
+ end
14
+
15
+ it "finds old data attributes" do
16
+ expect(found(%{<a data-toggle="modal" data-target="#m"></a>})).to eq(%w[data-toggle data-target])
17
+ end
18
+
19
+ it "leaves Bootstrap 5 data attributes alone" do
20
+ expect(found(%{<a data-bs-toggle="modal" data-bs-target="#m"></a>})).to be_empty
21
+ end
22
+
23
+ it "finds old data attributes in Ruby hashes" do
24
+ expect(found(%{<%= link_to "x", "#", data: { toggle: "modal" } %>})).to eq(%w[data-toggle])
25
+ expect(found(%{<%= link_to "x", "#", :data => { :dismiss => "modal" } %>})).to eq(%w[data-dismiss])
26
+ end
27
+
28
+ it "finds old classes in each Ruby hash style" do
29
+ expect(found(%{<%= link_to "x", "#", class: "btn btn-default" %>})).to eq(%w[btn-default])
30
+ expect(found(%{<%= link_to "x", "#", :class => 'btn-xs' %>})).to eq(%w[btn-xs])
31
+ end
32
+
33
+ it "ignores interpolated code inside a class attribute" do
34
+ expect(found('<div class="<%= close %> #{well}"></div>')).to be_empty
35
+ end
36
+
37
+ it "matches whole class names only" do
38
+ expect(found(%{<div class="my-panel closed wells"></div>})).to be_empty
39
+ end
40
+
41
+ it "ignores the same words outside class attributes" do
42
+ expect(found(%{<p>Close the panel, it went well.</p>})).to be_empty
43
+ end
44
+
45
+ it "rewrites numbered classes" do
46
+ finding = described_class.scan(%{<div class="col-xs-6 ml-3 pr-md-2"></div>}, ".erb")
47
+
48
+ expect(finding.map { |f| f[:replacement] }).to eq(%w[col-6 ms-3 pe-md-2])
49
+ end
50
+
51
+ it "finds class shorthand in Haml and Slim" do
52
+ expect(found("%button.btn.btn-default Save", ".haml")).to eq(%w[btn-default])
53
+ expect(found(".form-group\n = f.label :x", ".haml")).to eq(%w[form-group])
54
+ expect(found("button.btn-xs Save", ".slim")).to eq(%w[btn-xs])
55
+ end
56
+
57
+ it "does not treat plain Haml text as class shorthand" do
58
+ expect(found("Visit example.close today", ".haml")).to be_empty
59
+ end
60
+
61
+ # The gem can't tell agents off for markup it ships itself.
62
+ it "finds nothing in the markup this gem ships" do
63
+ root = File.expand_path("../../..", __dir__)
64
+ files = Dir[File.join(root, "lib/generators/**/templates/**/*"), File.join(root, "app/views/**/*"), File.join(root, "app/helpers/**/*")]
65
+ .select { |f| File.file?(f) }
66
+
67
+ offenders = files.flat_map do |file|
68
+ described_class.scan(File.read(file), File.extname(file))
69
+ .map { |f| "#{file.sub("#{root}/", '')}:#{f[:line]} #{f[:found]}" }
70
+ end
71
+
72
+ expect(offenders).to eq([])
73
+ end
74
+ end
@@ -28,35 +28,48 @@ describe ModalHelper, :type => :helper do
28
28
  end
29
29
 
30
30
  it 'renders a close button' do
31
- expect(close_button('modal')).to eql "<button class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>"
31
+ expect(close_button('modal')).to eql CLOSE_BUTTON
32
32
  end
33
33
 
34
+ it 'dismisses the modal when no dismiss target is given' do
35
+ expect(close_button(nil)).to eql CLOSE_BUTTON
36
+ end
37
+
38
+ it 'escapes the dismiss target' do
39
+ expect(close_button('"><script>')).not_to include('<script>')
40
+ end
41
+
42
+ it 'applies the requested size to the dialog' do
43
+ expect(modal_dialog(options.merge(:size => 'modal-lg'))).to have_tag('div.modal-dialog.modal-lg')
44
+ end
45
+
34
46
  it 'renders a modal toggle button' do
35
47
  expect(modal_toggle('Save', :href => "#modal").gsub(/\n/, "")).to eql MODAL_TOGGLE.gsub(/\n/, "")
36
48
  end
37
49
 
38
50
  it 'renders a cancel button' do
39
- expect(modal_cancel_button("Cancel", :data => {:dismiss => 'modal'}, :href => "#modal").gsub(/\n/, "")).to eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
51
+ expect(modal_cancel_button("Cancel", :href => "#modal").gsub(/\n/, "")).to eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
40
52
  end
41
53
  end
42
54
 
55
+ CLOSE_BUTTON = %q{<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>}
56
+
43
57
  BASIC_MODAL = <<-HTML
44
- <div class=\"bootstrap-modal modal fade\" id=\"modal\"><div class=\"modal-dialog \"><div class=\"modal-content\"><div class=\"modal-header\"><button class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button><h4 class=\"modal-title\">Modal header</h4></div><div class=\"modal-body\">This is the body</div><div class=\"modal-footer\"><button class="btn">Save</button></div></div></div></div>
58
+ <div class="bootstrap-modal modal fade" id="modal" tabindex="-1" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h5 class="modal-title">Modal header</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body">This is the body</div><div class="modal-footer"><button class="btn">Save</button></div></div></div></div>
45
59
  HTML
46
60
 
47
61
  MODAL_HEADER_WITHOUT_CLOSE = <<-HTML
48
- <div class="modal-header"><h4 class=\"modal-title\">Modal header</h4></div>
62
+ <div class="modal-header"><h5 class="modal-title">Modal header</h5></div>
49
63
  HTML
50
64
 
51
65
  MODAL_HEADER_WITH_CLOSE = <<-HTML
52
- <div class="modal-header"><button class="close" data-dismiss="modal" aria-hidden=\"true\">&times;</button><h4 class=\"modal-title\">Modal header</h4></div>
66
+ <div class="modal-header"><h5 class="modal-title">Modal header</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div>
53
67
  HTML
54
68
 
55
69
  MODAL_TOGGLE = <<-HTML
56
- <a class="btn btn-default" data-toggle="modal" href="#modal">Save</a>
70
+ <a class="btn btn-secondary" data-bs-toggle="modal" href="#modal">Save</a>
57
71
  HTML
58
72
 
59
73
  MODAL_CANCEL_BUTTON = <<-HTML
60
- <a class="btn bootstrap-modal-cancel-button" data-dismiss="modal" href="#modal">Cancel</a>
74
+ <a class="btn btn-secondary bootstrap-modal-cancel-button" data-bs-dismiss="modal" href="#modal">Cancel</a>
61
75
  HTML
62
-
@@ -40,6 +40,10 @@ describe NavbarHelper, :type => :helper do
40
40
  .to eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
41
41
  end
42
42
 
43
+ it "should mark an inverse navbar as dark" do
44
+ expect(nav_bar(:inverse => true)).to have_tag(:nav, with: { 'data-bs-theme' => 'dark' })
45
+ end
46
+
43
47
  it "should add the brand name and link it to the home page" do
44
48
  expect(nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase)
45
49
  .to eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
@@ -86,7 +90,7 @@ describe NavbarHelper, :type => :helper do
86
90
  menu_item("Home", "/") + menu_item("Products", "/products")
87
91
  end
88
92
 
89
- expect(element).to have_tag(:ul, with: {class: "nav navbar-nav"}) {
93
+ expect(element).to have_tag(:ul, with: {class: "navbar-nav"}) {
90
94
  with_tag(:li) {
91
95
  with_tag(:a, text: "Home", with: {href: "/"})
92
96
  }
@@ -96,12 +100,12 @@ describe NavbarHelper, :type => :helper do
96
100
  }
97
101
  end
98
102
 
99
- it "should return a ul with class .navbar-left when passed the {pull: :left} option" do
103
+ it "should return a ul with class .me-auto when passed the {pull: :left} option" do
100
104
  element = menu_group(pull: :left) do
101
105
  menu_item("Home", "/")
102
106
  end
103
107
 
104
- expect(element).to have_tag(:ul, with: {class: "nav navbar-nav navbar-left"}) {
108
+ expect(element).to have_tag(:ul, with: {class: "navbar-nav me-auto"}) {
105
109
  with_tag(:li) {
106
110
  with_tag(:a, text: "Home", with: {href: "/"})
107
111
  }
@@ -114,28 +118,30 @@ describe NavbarHelper, :type => :helper do
114
118
  allow(self).to receive(:current_page?) { false }
115
119
 
116
120
  element = menu_item("Home", "/")
117
- expect(element).to have_tag(:li) {
118
- with_tag(:a, text: "Home", with: { href: "/" })
121
+ expect(element).to have_tag(:li, with: {class: "nav-item"}) {
122
+ with_tag(:a, text: "Home", with: { href: "/", class: "nav-link" })
119
123
  }
124
+ expect(element).not_to have_tag(:a, with: {class: "active"})
120
125
  end
121
126
 
122
- it "should return the link with class 'active' if on current page" do
127
+ it "should mark the link, not the li, as active on the current page" do
123
128
  allow(self).to receive(:uri_state) { :active }
124
129
 
125
130
  element = menu_item("Home", "/")
126
- expect(element).to have_tag(:li, with: {class: "active"}) {
127
- with_tag(:a, text: "Home", with: { href: "/" })
131
+ expect(element).to have_tag(:li, with: {class: "nav-item"}) {
132
+ with_tag(:a, text: "Home", with: { href: "/", class: "nav-link active", "aria-current" => "page" })
128
133
  }
134
+ expect(element).not_to have_tag(:li, with: {class: "active"})
129
135
  end
130
136
 
131
137
  it "should pass any other options through to the link_to method" do
132
138
  allow(self).to receive_message_chain("uri_state").and_return(:active)
133
139
 
134
140
  element = menu_item("Log out", "/users/sign_out", class: "home_link", method: :delete)
135
- expect(element).to have_tag(:li, with: {class: "active"}) {
141
+ expect(element).to have_tag(:li) {
136
142
  with_tag(:a, text: "Log out", with: {
137
143
  href: "/users/sign_out",
138
- class: "home_link",
144
+ class: "nav-link active home_link",
139
145
  rel: "nofollow",
140
146
  "data-method" => "delete"
141
147
  })
@@ -166,9 +172,8 @@ describe NavbarHelper, :type => :helper do
166
172
  allow(self).to receive(:uri_state) { :active }
167
173
 
168
174
  element = menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }
169
- expect(element).to have_tag(:li, with: {class: "active"}) {
175
+ expect(element).to have_tag(:a, with: { href: "/", class: "nav-link active" }) {
170
176
  with_tag(:i, with: { class: "icon-home"})
171
- with_tag(:a, text: " Home", with: { href: "/"})
172
177
  }
173
178
  end
174
179
  end
@@ -178,8 +183,34 @@ describe NavbarHelper, :type => :helper do
178
183
  ele = drop_down "Products" do
179
184
  menu_item "Latest", "/"
180
185
  end
181
- expect(ele).to have_tag(:li, with: {class: 'dropdown'})
182
- expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
186
+ expect(ele).to have_tag(:li, with: {class: 'nav-item dropdown'})
187
+ expect(ele).to have_tag(:a, with: {class: 'nav-link dropdown-toggle', role: 'button', 'data-bs-toggle' => 'dropdown', 'aria-expanded' => 'false'})
188
+ expect(ele).not_to have_tag(:b, with: {class: 'caret'})
189
+ end
190
+
191
+ it "should render items inside it as dropdown items, not nav links" do
192
+ ele = drop_down "Products" do
193
+ menu_item "Latest", "/"
194
+ end
195
+ expect(ele).to have_tag(:a, text: "Latest", with: {class: 'dropdown-item'})
196
+ expect(ele).not_to have_tag(:a, text: "Latest", with: {class: 'nav-link'})
197
+ end
198
+
199
+ it "should render items after it as nav links again" do
200
+ drop_down("Products") { menu_item "Latest", "/" }
201
+ expect(menu_item("Home", "/")).to have_tag(:a, with: {class: 'nav-link'})
202
+ end
203
+ end
204
+
205
+ describe "drop_down_divider" do
206
+ it "should render a dropdown divider" do
207
+ expect(drop_down_divider).to have_tag(:li) { with_tag(:hr, with: {class: 'dropdown-divider'}) }
208
+ end
209
+ end
210
+
211
+ describe "drop_down_header" do
212
+ it "should render a dropdown header" do
213
+ expect(drop_down_header("Fruit")).to have_tag(:li) { with_tag(:h6, text: "Fruit", with: {class: 'dropdown-header'}) }
183
214
  end
184
215
  end
185
216
 
@@ -194,30 +225,42 @@ describe NavbarHelper, :type => :helper do
194
225
  expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
195
226
  expect(ele).to have_tag(:ul, with: {class: 'dropdown-menu'})
196
227
  end
228
+
229
+ # Bootstrap 5 has no nested dropdowns, so a submenu becomes a labelled group.
230
+ it "should render the submenu as a header followed by its items" do
231
+ ele = drop_down_with_submenu "Products" do
232
+ drop_down_submenu "Latest" do
233
+ menu_item "Option1", "/"
234
+ end
235
+ end
236
+ expect(ele).to have_tag(:h6, text: "Latest", with: {class: 'dropdown-header'})
237
+ expect(ele).to have_tag(:a, text: "Option1", with: {class: 'dropdown-item'})
238
+ expect(ele).not_to have_tag(:li, with: {class: 'dropdown-submenu'})
239
+ end
197
240
  end
198
241
 
199
242
  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>'
243
+ it "should render a vertical rule" do
244
+ expect(menu_divider).to have_tag(:li, with: {class: 'nav-item'}) { with_tag(:div, with: {class: 'vr'}) }
202
245
  end
203
246
  end
204
247
 
205
248
  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>")
249
+ it "should render text within span tags with class 'navbar-text" do
250
+ expect(menu_text("Strapline!")).to match("<span class=\"navbar-text\">Strapline!</span>")
208
251
  end
209
252
 
210
253
  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>")
254
+ expect(menu_text("I am being pulled right", :pull => :right)).to match("<span class=\"ms-auto navbar-text\">I am being pulled right</span>")
212
255
  end
213
256
 
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>")
257
+ it "should be able to cope with arbitrary options being passed to the span tag" do
258
+ expect(menu_text("I am classy!", :class => "classy", :id => "classy_text")).to match("<span class=\"classy navbar-text\" id=\"classy_text\">I am classy!</span>")
216
259
  end
217
260
 
218
261
  it "should be able to cope with a block too" do
219
262
  ele = menu_text("I have been rendered programmatically!")
220
- expect(ele).to have_tag(:p, with: {class: "navbar-text"})
263
+ expect(ele).to have_tag(:span, with: {class: "navbar-text"})
221
264
  expect(ele).to match "I have been rendered programmatically!"
222
265
  end
223
266
  end
@@ -236,7 +279,7 @@ describe NavbarHelper, :type => :helper do
236
279
 
237
280
  describe "default navbar" do
238
281
  it "renders a navbar" do
239
- expect(nav_bar { 'foo' }).to have_tag(:nav, with: { class: 'navbar navbar-default', role: 'navigation' }, text: /foo/)
282
+ expect(nav_bar { 'foo' }).to have_tag(:nav, with: { class: 'navbar navbar-expand bg-body-tertiary', role: 'navigation' }, text: /foo/)
240
283
  end
241
284
  end
242
285
 
@@ -245,42 +288,42 @@ end
245
288
  # HTML output
246
289
 
247
290
  BASIC_NAVBAR = <<-HTML
248
- <nav class="navbar navbar-default" role="navigation">
291
+ <nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
249
292
  <div class="container">
250
293
  </div>
251
294
  </nav>
252
295
  HTML
253
296
 
254
297
  FIXED_TOP_NAVBAR = <<-HTML
255
- <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
298
+ <nav class="navbar navbar-expand bg-body-tertiary fixed-top" role="navigation">
256
299
  <div class="container">
257
300
  </div>
258
301
  </nav>
259
302
  HTML
260
303
 
261
304
  STATIC_TOP_NAVBAR = <<-HTML
262
- <nav class="navbar navbar-default navbar-static-top" role="navigation">
305
+ <nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
263
306
  <div class="container">
264
307
  </div>
265
308
  </nav>
266
309
  HTML
267
310
 
268
311
  FIXED_BOTTOM_NAVBAR = <<-HTML
269
- <nav class="navbar navbar-default navbar-fixed-bottom" role="navigation">
312
+ <nav class="navbar navbar-expand bg-body-tertiary fixed-bottom" role="navigation">
270
313
  <div class="container">
271
314
  </div>
272
315
  </nav>
273
316
  HTML
274
317
 
275
318
  INVERSE_NAVBAR = <<-HTML
276
- <nav class="navbar navbar-default navbar-inverse" role="navigation">
319
+ <nav class="navbar navbar-expand bg-dark" data-bs-theme="dark" role="navigation">
277
320
  <div class="container">
278
321
  </div>
279
322
  </nav>
280
323
  HTML
281
324
 
282
325
  NAVBAR_WITH_BRAND = <<-HTML
283
- <nav class="navbar navbar-default" role="navigation">
326
+ <nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
284
327
  <div class="container">
285
328
  <a class="navbar-brand" href="/">
286
329
  Ninety Ten
@@ -290,7 +333,7 @@ NAVBAR_WITH_BRAND = <<-HTML
290
333
  HTML
291
334
 
292
335
  NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
293
- <nav class="navbar navbar-default" role="navigation">
336
+ <nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
294
337
  <div class="container">
295
338
  <a class="navbar-brand" href="http://www.ninetyten.com">
296
339
  Ninety Ten
@@ -300,49 +343,39 @@ NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
300
343
  HTML
301
344
 
302
345
  RESPONSIVE_NAVBAR = <<-HTML
303
- <nav class="navbar navbar-default" role="navigation">
346
+ <nav class="navbar navbar-expand-lg bg-body-tertiary" role="navigation">
304
347
  <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">
348
+ <button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-label="Toggle navigation">
349
+ <span class="navbar-toggler-icon"></span>
350
+ </button>
351
+ <div class="collapse navbar-collapse">
314
352
  </div>
315
353
  </div>
316
354
  </nav>
317
355
  HTML
318
356
 
319
357
  RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
320
- <nav class="navbar navbar-default" role="navigation">
358
+ <nav class="navbar navbar-expand-lg bg-body-tertiary" role="navigation">
321
359
  <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>
360
+ <button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-label="Toggle navigation">
361
+ <span class="navbar-toggler-icon"></span>
362
+ </button>
363
+ <div class="collapse navbar-collapse">
364
+ <p>Passing a block</p>
332
365
  </div>
333
366
  </div>
334
367
  </nav>
335
368
  HTML
336
369
 
337
370
  PLAIN_NAVBAR_WITH_ITEM = <<-HTML
338
- <nav class="navbar navbar-default" role="navigation">
371
+ <nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
339
372
  <div class="container">
340
- <ul class="nav navbar-nav">
341
- <li>
342
- <a href="/">Home</a>
373
+ <ul class="navbar-nav">
374
+ <li class="nav-item">
375
+ <a class="nav-link" href="/">Home</a>
343
376
  </li>
344
- <li>
345
- <a href="/products">Products</a>
377
+ <li class="nav-item">
378
+ <a class="nav-link" href="/products">Products</a>
346
379
  </li>
347
380
  </ul>
348
381
  </div>
@@ -350,47 +383,16 @@ PLAIN_NAVBAR_WITH_ITEM = <<-HTML
350
383
  HTML
351
384
 
352
385
  BRANDED_NAVBAR_WITH_ITEM = <<-HTML
353
- <nav class="navbar navbar-default" role="navigation">
386
+ <nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
354
387
  <div class="container">
355
388
  <a class="navbar-brand" href="/">
356
389
  Something
357
390
  </a>
358
- <ul class="nav navbar-nav">
359
- <li>
360
- <a href="/">Home</a>
391
+ <ul class="navbar-nav">
392
+ <li class="nav-item">
393
+ <a class="nav-link" href="/">Home</a>
361
394
  </li>
362
395
  </ul>
363
396
  </div>
364
397
  </nav>
365
398
  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=\"&#x2713;\"/>
391
- </div>
392
- <input id=\"search_stub\" name=\"search[stub]\" type=\"text\"/>
393
- </form>
394
- </div>
395
- </nav>
396
- HTML
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,6 @@ require 'rspec-html-matchers'
13
13
  require 'twitter-bootstrap-rails'
14
14
  require 'abstract_controller'
15
15
  require 'action_controller'
16
- require 'mocha/api'
17
16
  require 'pry'
18
17
 
19
18
  require 'twitter/bootstrap/rails/version'
@@ -8,6 +8,8 @@ require 'generators/bootstrap/install/install_generator'
8
8
  require 'generators/bootstrap/layout/layout_generator'
9
9
  require 'generators/bootstrap/starter/starter_generator'
10
10
  require 'generators/bootstrap/cdn/cdn_generator'
11
+ require 'generators/bootstrap/doctor/doctor_generator'
12
+ require 'generators/bootstrap/agent/agent_generator'
11
13
  require 'generators/bootstrap/snippets/snippet_catalog'
12
14
 
13
15
  Bootstrap::Generators::SnippetCatalog::GENERATORS.each_key do |name|