bh 6.0.0 → 6.1.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +5 -0
  5. data/app/views/bh/_table.html.erb +2 -4
  6. data/bh.gemspec +8 -7
  7. data/lib/bh/bootstrap_helpers.rb +10 -4
  8. data/lib/bh/version.rb +1 -1
  9. metadata +3 -45
  10. data/Rakefile +0 -11
  11. data/gemfiles/Gemfile.rails-3.x +0 -8
  12. data/gemfiles/Gemfile.rails-4.x +0 -8
  13. data/gemfiles/Gemfile.rails-5.x +0 -7
  14. data/spec/padrino/button_to_helper.rb +0 -35
  15. data/spec/padrino/link_to_helper.rb +0 -12
  16. data/spec/padrino_spec.rb +0 -29
  17. data/spec/rails/button_to_helper.rb +0 -31
  18. data/spec/rails/form/check_box_helper_spec.rb +0 -112
  19. data/spec/rails/form/field_helper_spec.rb +0 -138
  20. data/spec/rails/form/fields_for_helper_spec.rb +0 -65
  21. data/spec/rails/form/fieldset_helper_spec.rb +0 -32
  22. data/spec/rails/form/file_field_helper_spec.rb +0 -74
  23. data/spec/rails/form/legend_helper_spec.rb +0 -35
  24. data/spec/rails/form/radio_button_helper_spec.rb +0 -89
  25. data/spec/rails/form/select_helper_spec.rb +0 -88
  26. data/spec/rails/form/static_control_helper_spec.rb +0 -67
  27. data/spec/rails/form/submit_helper_spec.rb +0 -30
  28. data/spec/rails/form_for_helper_spec.rb +0 -50
  29. data/spec/rails/link_to_helper.rb +0 -12
  30. data/spec/rails_helper.rb +0 -24
  31. data/spec/rails_spec.rb +0 -29
  32. data/spec/shared/alert_box_helper.rb +0 -62
  33. data/spec/shared/button_helper.rb +0 -52
  34. data/spec/shared/button_to_helper.rb +0 -51
  35. data/spec/shared/cdn_helper.rb +0 -36
  36. data/spec/shared/dropdown_helper.rb +0 -112
  37. data/spec/shared/glyphicon_helper.rb +0 -21
  38. data/spec/shared/horizontal_helper.rb +0 -37
  39. data/spec/shared/icon_helper.rb +0 -31
  40. data/spec/shared/link_to_helper.rb +0 -84
  41. data/spec/shared/modal_helper.rb +0 -104
  42. data/spec/shared/nav_helper.rb +0 -49
  43. data/spec/shared/navbar_helper.rb +0 -63
  44. data/spec/shared/panel_helper.rb +0 -76
  45. data/spec/shared/panel_row_helper.rb +0 -21
  46. data/spec/shared/progress_bar_helper.rb +0 -103
  47. data/spec/shared/vertical_helper.rb +0 -43
  48. data/spec/spec_helper.rb +0 -22
  49. data/spec/support/matchers.rb +0 -47
  50. data/spec/support/padrino.rb +0 -33
  51. data/spec/support/rails.rb +0 -27
@@ -1,52 +0,0 @@
1
- shared_examples_for 'the button helper' do
2
- all_tests_pass_with 'no button options'
3
- all_tests_pass_with 'extra button options'
4
- all_tests_pass_with 'the :context button option'
5
- all_tests_pass_with 'the :size button option'
6
- all_tests_pass_with 'the :layout button option'
7
- end
8
-
9
- #--
10
-
11
- shared_examples_for 'no button options' do
12
- specify 'sets the class to "btn btn-default"' do
13
- html = '<button class="btn btn-default">content</button>'
14
- expect(:button).to generate html
15
- end
16
- end
17
-
18
-
19
- shared_examples_for 'extra button options' do
20
- specify 'passes the options to the wrapping <button>' do
21
- options = {class: 'important', data: {value: 1}, id: 'my-button'}
22
- html = '<button class="important btn btn-default" data-value="1" id="my-button">content</button>'
23
- expect(button: options).to generate html
24
- end
25
- end
26
-
27
- shared_examples_for 'the :context button option' do
28
- Bh::Button.contexts.each do |context, context_class|
29
- specify %Q{set to :#{context}, adds the class "#{context_class}"} do
30
- html = %Q{<button class="btn #{context_class}">content</button>}
31
- expect(button: {context: context}).to generate html
32
- end
33
- end
34
- end
35
-
36
- shared_examples_for 'the :size button option' do
37
- Bh::Button.sizes.each do |size, size_class|
38
- specify %Q{set to :#{size}, adds the class "#{size_class}"} do
39
- html = %Q{<button class="btn btn-default #{size_class}">content</button>}
40
- expect(button: {size: size}).to generate html
41
- end
42
- end
43
- end
44
-
45
- shared_examples_for 'the :layout button option' do
46
- Bh::Button.layouts.each do |layout, layout_class|
47
- specify %Q{set to :#{layout}, adds the class "#{layout_class}"} do
48
- html = %Q{<button class="btn btn-default #{layout_class}">content</button>}
49
- expect(button: {layout: layout}).to generate html
50
- end
51
- end
52
- end
@@ -1,51 +0,0 @@
1
- shared_examples_for 'the button_to helper' do
2
- all_tests_pass_with 'the :context button_to option'
3
- all_tests_pass_with 'the :size button_to option'
4
- all_tests_pass_with 'the :layout button_to option'
5
- all_tests_pass_with 'the button wrapped in navbar'
6
- all_tests_pass_with 'the button wrapped in nav'
7
- end
8
-
9
- #--
10
-
11
- shared_examples_for 'the :context button_to option' do
12
- Bh::Button.contexts.each do |context, context_class|
13
- specify %Q{set to :#{context}, adds the class "#{context_class}"} do
14
- html = %r{<(input|button).+class="btn #{context_class}"}
15
- expect(button_to: {context: context}).to generate html
16
- end
17
- end
18
- end
19
-
20
- shared_examples_for 'the :size button_to option' do
21
- Bh::Button.sizes.each do |size, size_class|
22
- specify %Q{set to :#{size}, adds the class "#{size_class}"} do
23
- html = %r{<(input|button).+class="btn btn-default #{size_class}"}
24
- expect(button_to: {size: size}).to generate html
25
- end
26
- end
27
- end
28
-
29
- shared_examples_for 'the :layout button_to option' do
30
- Bh::Button.layouts.each do |layout, layout_class|
31
- specify %Q{set to :#{layout}, adds the class "#{layout_class}"} do
32
- html = %r{<(input|button).+class="btn btn-default #{layout_class}"}
33
- expect(button_to: {layout: layout}).to generate html
34
- end
35
- end
36
- end
37
-
38
- shared_examples_for 'the button wrapped in navbar' do
39
- specify 'adds the "navbar-form" class to the form' do
40
- html = %r{^<form.+class="navbar-form"}
41
- bh.navbar { expect(button_to: {context: :default}).to generate html }
42
- end
43
- end
44
-
45
-
46
- shared_examples_for 'the button wrapped in nav' do
47
- specify 'surrounds the form in a <li> item' do
48
- html = %r{^<li><form.+?</form></li>}
49
- bh.nav { expect(:button_to).to generate html }
50
- end
51
- end
@@ -1,36 +0,0 @@
1
- shared_examples_for 'the bootstrap_css helper' do
2
- it { expect(:bootstrap_css).to link_to_existing_file }
3
- end
4
-
5
- shared_examples_for 'the bootstrap_theme_css helper' do
6
- it { expect(:bootstrap_theme_css).to link_to_existing_file }
7
- end
8
-
9
- shared_examples_for 'the bootstrap_js helper' do
10
- it { expect(:bootstrap_js).to link_to_existing_file }
11
- end
12
-
13
- shared_examples_for 'the font_awesome_css helper' do
14
- it { expect(:font_awesome_css).to link_to_existing_file }
15
- end
16
-
17
- #--
18
-
19
- RSpec::Matchers.define :link_to_existing_file do
20
- match do |helper|
21
- require 'open-uri'
22
- open_uri_options = {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}
23
-
24
- # via HTTP
25
- open bh.send(helper, scheme: :http), open_uri_options
26
-
27
- # via HTTPS
28
- open bh.send(helper, scheme: :https), open_uri_options
29
-
30
- # non-minified
31
- open bh.send(helper, scheme: :http, minified: false), open_uri_options
32
-
33
- # legacy version
34
- open bh.send(helper, scheme: :http, version: '3.1.0'), open_uri_options
35
- end
36
- end
@@ -1,112 +0,0 @@
1
- shared_examples_for 'the dropdown helper' do
2
- all_tests_pass_with 'no dropdown options'
3
- all_tests_pass_with 'the :id dropdown option'
4
- all_tests_pass_with 'the :context dropdown option'
5
- all_tests_pass_with 'the :size dropdown option'
6
- all_tests_pass_with 'the :layout dropdown option'
7
- all_tests_pass_with 'the :groupable dropdown option'
8
- all_tests_pass_with 'the :direction dropdown option'
9
- all_tests_pass_with 'the :align dropdown option'
10
- all_tests_pass_with 'the :split dropdown option'
11
- all_tests_pass_with 'the button: :class dropdown option'
12
- end
13
-
14
- #--
15
-
16
- shared_examples_for 'no dropdown options' do
17
- specify 'displays a button with the caption and the caret to toggle a menu' do
18
- html = <<-EOT.strip_heredoc.strip
19
- <div class="btn-group">
20
- <button class="dropdown-toggle btn btn-default" type="button" id="(.+)" data-toggle="dropdown">
21
- caption
22
- <span class=\"caret\"><\/span>
23
- <\/button>
24
- <ul class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"\\1\">
25
- content
26
- <\/ul>
27
- <\/div>
28
- EOT
29
- expect(:dropdown).to generate %r{#{html}}
30
- end
31
- end
32
-
33
- shared_examples_for 'the :id dropdown option' do
34
- specify 'uses the ID to connect button and ul' do
35
- id = 'my-modal'
36
- expect(dropdown: {id: id}).to generate %r{<button.+id="#{id}".*>}
37
- expect(dropdown: {id: id}).to generate %r{<ul.+aria-labelledby="#{id}".*>}
38
- end
39
- end
40
-
41
- shared_examples_for 'the :context dropdown option' do
42
- Bh::Button.contexts.each do |context, context_class|
43
- specify %Q{set to :#{context}, adds the class "#{context_class}"} do
44
- html = %r{<button class="dropdown-toggle btn #{context_class}"}
45
- expect(dropdown: {context: context}).to generate html
46
- end
47
- end
48
- end
49
-
50
- shared_examples_for 'the :size dropdown option' do
51
- Bh::Button.sizes.each do |size, size_class|
52
- specify %Q{set to :#{size}, adds the class "#{size_class}"} do
53
- html = %r{<button class="dropdown-toggle btn btn-default #{size_class}"}
54
- expect(dropdown: {size: size}).to generate html
55
- end
56
- end
57
- end
58
-
59
- shared_examples_for 'the :layout dropdown option' do
60
- Bh::Button.layouts.each do |layout, layout_class|
61
- specify %Q{set to :#{layout}, adds the class "#{layout_class}"} do
62
- html = %r{<button class="dropdown-toggle btn btn-default #{layout_class}"}
63
- expect(dropdown: {layout: layout}).to generate html
64
- end
65
- end
66
- end
67
-
68
- shared_examples_for 'the :groupable dropdown option' do
69
- Bh::Dropdown.groupables.each do |groupable, groupable_class|
70
- specify %Q{set to :#{groupable}, adds the class "#{groupable_class}"} do
71
- html = %r{^<div class="#{groupable_class}">}
72
- expect(dropdown: {groupable: groupable}).to generate html
73
- end
74
- end
75
- end
76
-
77
- shared_examples_for 'the :direction dropdown option' do
78
- Bh::Dropdown.directions.each do |direction, direction_class|
79
- specify %Q{set to :#{direction}, adds the class "#{direction_class}"} do
80
- html = %r{^<div class="btn-group #{direction_class}">}
81
- expect(dropdown: {direction: direction}).to generate html
82
- end
83
- end
84
- end
85
-
86
- shared_examples_for 'the :align dropdown option' do
87
- Bh::Dropdown.aligns.each do |align, align_class|
88
- specify %Q{set to :#{align}, adds the class "#{align_class}"} do
89
- html = %r{<ul class="dropdown-menu #{align_class}" role="menu"}
90
- expect(dropdown: {align: align}).to generate html
91
- end
92
- end
93
- end
94
-
95
- shared_examples_for 'the :split dropdown option' do
96
- html = %r{<button type="button" class="btn btn-default">caption</button>}
97
-
98
- specify %Q{set to truthy, splits the caption and the caret} do
99
- expect(dropdown: {split: true}).to generate html
100
- end
101
-
102
- specify %Q{set to falsey, does not split the caption and the caret} do
103
- expect(dropdown: {split: false}).not_to generate html
104
- end
105
- end
106
-
107
- shared_examples_for 'the button: :class dropdown option' do
108
- specify 'appends the class to the modal button' do
109
- html = %r{<button class="dropdown-toggle important btn btn-default"}
110
- expect(dropdown: {button: {class: 'important'}}).to generate html
111
- end
112
- end
@@ -1,21 +0,0 @@
1
- shared_examples_for 'the glyphicon helper' do
2
- all_tests_pass_with 'no glyphicon options'
3
- all_tests_pass_with 'extra glyphicon options'
4
- end
5
-
6
- #--
7
-
8
- shared_examples_for 'no glyphicon options' do
9
- specify 'creates a <span> with an icon' do
10
- html = '<span class="glyphicon glyphicon-zoom-in"></span>'
11
- expect(:glyphicon).to generate html
12
- end
13
- end
14
-
15
- shared_examples_for 'extra glyphicon options' do
16
- specify 'passes the options to the <span>' do
17
- options = {class: 'important', data: {value: 1}, id: 'my-glyphicon'}
18
- html = '<span class="important glyphicon glyphicon-zoom-in" data-value="1" id="my-glyphicon"></span>'
19
- expect(glyphicon: options).to generate html
20
- end
21
- end
@@ -1,37 +0,0 @@
1
- shared_examples_for 'the horizontal helper' do
2
- all_tests_pass_with 'the horizontal not wrapped in navbar'
3
- all_tests_pass_with 'no horizontal options'
4
- all_tests_pass_with 'extra horizontal options (except :id)'
5
- all_tests_pass_with 'the horizontal wrapped in a navbar with :id'
6
- end
7
-
8
- #--
9
-
10
- shared_examples_for 'the horizontal not wrapped in navbar' do
11
- specify 'returns nil' do
12
- expect(:horizontal).to generate nil
13
- end
14
- end
15
-
16
- shared_examples_for 'no horizontal options' do
17
- specify 'creates a <div class="collpase navbar-collapse"> element' do
18
- html = %r{<div class="collapse navbar-collapse" id=".+">content</div>}
19
- bh.navbar { expect(:horizontal).to generate html }
20
- end
21
- end
22
-
23
- shared_examples_for 'extra horizontal options (except :id)' do
24
- specify 'passes the options to the <div> element' do
25
- options = {class: 'important', data: {value: 1}}
26
- html = %r{<div class="important collapse navbar-collapse" data-value="1"}
27
- bh.navbar { expect(horizontal: options).to generate html }
28
- end
29
- end
30
-
31
- shared_examples_for 'the horizontal wrapped in a navbar with :id' do
32
- it 'uses the id from the navbar' do
33
- id = 'my-navbar'
34
- html = %r{<div class="collapse navbar-collapse" id="my-navbar">content</div>}
35
- bh.navbar(id: id) { expect(:horizontal).to generate html}
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- shared_examples_for 'the icon helper' do
2
- all_tests_pass_with 'no icon options'
3
- all_tests_pass_with 'extra icon options'
4
- all_tests_pass_with 'the :library icon option'
5
- end
6
-
7
- #--
8
-
9
- shared_examples_for 'no icon options' do
10
- specify 'creates a <span> with an icon' do
11
- html = '<span class="glyphicon glyphicon-zoom-in"></span>'
12
- expect(:icon).to generate html
13
- end
14
- end
15
-
16
- shared_examples_for 'extra icon options' do
17
- specify 'passes the options to the <span>' do
18
- options = {class: 'important', data: {value: 1}, id: 'my-icon'}
19
- html = '<span class="important glyphicon glyphicon-zoom-in" data-value="1" id="my-icon"></span>'
20
- expect(icon: options).to generate html
21
- end
22
- end
23
-
24
- shared_examples_for 'the :library icon option' do
25
- Bh::Icon.libraries.each do |library, library_class|
26
- specify %Q{set to :#{library}, adds the class "#{library_class}"} do
27
- html = %Q{<span class="#{library_class} #{library_class}-zoom-in"></span>}
28
- expect(icon: {library: library}).to generate html
29
- end
30
- end
31
- end
@@ -1,84 +0,0 @@
1
- shared_examples_for 'the link_to helper' do
2
- all_tests_pass_with 'no link_to options'
3
- all_tests_pass_with 'extra link_to options'
4
- all_tests_pass_with 'the link wrapped in alert_box'
5
- all_tests_pass_with 'the link wrapped in dropdown'
6
- all_tests_pass_with 'the link wrapped in nav'
7
- all_tests_pass_with 'the link wrapped in vertical'
8
- all_tests_pass_with 'the link including unsafe Javascript'
9
- all_tests_pass_with 'the link including safe HTML content'
10
- end
11
-
12
- #--
13
-
14
- shared_examples_for 'no link_to options' do
15
- specify 'matches the behavior of the framework-defined link_to' do
16
- html = '<a href="/">content</a>'
17
- expect(:link_to).to generate html
18
- end
19
- end
20
-
21
- shared_examples_for 'extra link_to options' do
22
- specify 'passes the options to the <a>' do
23
- options = {class: 'important', data: {value: 1}, id: 'my-link'}
24
- html = %r{^<a.+class="important" data-value="1".+id="my-link".*>content</a>$}
25
- expect(link_to: options).to generate html
26
- end
27
- end
28
-
29
- shared_examples_for 'the link wrapped in alert_box' do
30
- specify 'adds the "alert-link" class to the link' do
31
- html = %r{^<a.+class="alert-link".*>content</a>$}
32
- bh.alert_box { expect(:link_to).to generate html }
33
- end
34
- end
35
-
36
- shared_examples_for 'the link wrapped in dropdown' do
37
- specify 'surrounds the link in a <li> and adds role and tabindex' do
38
- html = %r{<li role="presentation"><a.+role="menuitem" tabindex="-1".*>content</a></li>}
39
- bh.dropdown('') { expect(:link_to).to generate html }
40
- end
41
- end
42
-
43
- shared_examples_for 'the link wrapped in nav' do
44
- specify 'surrounds the link in a <li> item' do
45
- html = '<li><a href="/">content</a></li>'
46
- bh.nav { expect(:link_to).to generate html }
47
- end
48
-
49
- describe 'if the link is to the current page' do
50
- before { allow_any_instance_of(Bh::LinkTo).to receive(:current_page?).and_return true }
51
-
52
- specify 'surrounds the link in a <li class="active"> item' do
53
- html = '<li class="active"><a href="/">content</a></li>'
54
- bh.nav { expect(:link_to).to generate html }
55
- end
56
- end
57
- end
58
-
59
- shared_examples_for 'the link wrapped in vertical' do
60
- specify 'adds the "navbar-brand" class to the link' do
61
- html = %r{^<a.+class="navbar-brand".*>content</a>$}
62
- bh.navbar(id: 'id') do
63
- bh.vertical { expect(:link_to).to generate html }
64
- end
65
- end
66
- end
67
-
68
- shared_examples_for 'the link including unsafe Javascript' do
69
- specify 'uses the original link_to helper which escapes the link' do
70
- expect(link_to: :xss_script).not_to generate %r{<script>}
71
- bh.alert_box { expect(link_to: :xss_script).not_to generate %r{<script>} }
72
- bh.dropdown('') { expect(link_to: :xss_script).not_to generate %r{<script>} }
73
- bh.nav { expect(link_to: :xss_script).not_to generate %r{<script>} }
74
- bh.navbar(id: 'id') do
75
- bh.vertical { expect(link_to: :xss_script).not_to generate %r{<script>} }
76
- end
77
- end
78
- end
79
-
80
- shared_examples_for 'the link including safe HTML content' do
81
- specify 'does not escape the HTML content' do
82
- expect(link_to: :safe_html).to generate %r{<hr />}
83
- end
84
- end
@@ -1,104 +0,0 @@
1
- shared_examples_for 'the modal helper' do
2
- all_tests_pass_with 'no modal options'
3
- all_tests_pass_with 'the :id modal option'
4
- all_tests_pass_with 'the :body modal option'
5
- all_tests_pass_with 'the :title modal option'
6
- all_tests_pass_with 'the :size modal option'
7
- all_tests_pass_with 'the button: :caption modal option'
8
- all_tests_pass_with 'the button: :context modal option'
9
- all_tests_pass_with 'the button: :size modal option'
10
- all_tests_pass_with 'the button: :class modal option'
11
- end
12
-
13
- #--
14
-
15
- shared_examples_for 'no modal options' do
16
- specify 'sets the role and the class to "modal", uses a generated ID and uses "Modal" as the title and caption' do
17
- html = <<-EOT.strip_heredoc.strip
18
- <button class="btn btn-default" data-toggle="modal" data-target="#(.+)">Modal<\/button>
19
- <div class="modal fade" id="\\1" tabindex="-1" role="dialog" aria-labelledby="label-\\1" aria-hidden="true">
20
- <div class="modal-dialog">
21
- <div class="modal-content">
22
- <div class="modal-header">
23
- <button type="button" class="close" data-dismiss="modal">
24
- <span aria-hidden="true">&times;<\/span><span class="sr-only">Close<\/span>
25
- <\/button>
26
- <h4 class="modal-title" id="label-\\1">Modal<\/h4>
27
- <\/div>
28
- (<div class=\"modal-body\">)*content(</div>)*
29
- <\/div>
30
- <\/div>
31
- <\/div>
32
- EOT
33
- expect(:modal).to generate %r{#{html}}
34
- end
35
- end
36
-
37
- shared_examples_for 'the :id modal option' do
38
- specify 'uses the ID to connect button and modal' do
39
- id = 'my-modal'
40
- expect(modal: {id: id}).to generate %r{<button.+data-target="##{id}">Modal<\/button>}
41
- expect(modal: {id: id}).to generate %r{<div.+id="#{id}".+aria-labelledby="label-#{id}".+>}
42
- expect(modal: {id: id}).to generate %r{<h4.+id="label-#{id}">Modal<\/h4>}
43
- end
44
- end
45
-
46
- shared_examples_for 'the :body modal option' do
47
- let(:html) { %r{<div class="modal-body">Body</div>} }
48
-
49
- specify 'given either a content or a block, is ignored' do
50
- expect(modal: {body: 'Body'}).not_to generate html
51
- end
52
-
53
- specify 'given neither content nor a block, it is displayed as the content' do
54
- expect(bh.modal(body: 'Body')).to match html
55
- end
56
- end
57
-
58
- shared_examples_for 'the :title modal option' do
59
- specify 'sets the modal title to the given value' do
60
- html = %r{<h4 class="modal-title".+>Title</h4>}
61
- expect(modal: {title: 'Title'}).to generate html
62
- end
63
- end
64
-
65
- shared_examples_for 'the :size modal option'do
66
- Bh::Modal.dialog_sizes.each do |size, size_class|
67
- specify %Q{set to :#{size}, adds the class "#{size_class}"} do
68
- html = %r{<div class="modal-dialog #{size_class}">}
69
- expect(modal: {size: size}).to generate html
70
- end
71
- end
72
- end
73
-
74
- shared_examples_for 'the button: :caption modal option' do
75
- specify 'sets the button caption to the given value' do
76
- html = %r{<button.+>Click me</button>}
77
- expect(modal: {button: {caption: 'Click me'}}).to generate html
78
- end
79
- end
80
-
81
- shared_examples_for 'the button: :context modal option' do
82
- Bh::Button.contexts.each do |context, context_class|
83
- specify %Q{set to :#{context}, adds the class "#{context_class}"} do
84
- html = %r{<button class="btn #{context_class}"}
85
- expect(modal: {button: {context: context}}).to generate html
86
- end
87
- end
88
- end
89
-
90
- shared_examples_for 'the button: :size modal option' do
91
- Bh::Button.sizes.each do |size, size_class|
92
- specify %Q{set to :#{size}, adds the class "#{size_class}"} do
93
- html = %r{<button class="btn btn-default #{size_class}"}
94
- expect(modal: {button: {size: size}}).to generate html
95
- end
96
- end
97
- end
98
-
99
- shared_examples_for 'the button: :class modal option' do
100
- specify 'appends the class to the modal button' do
101
- html = %r{<button class="important btn btn-default"}
102
- expect(modal: {button: {class: 'important'}}).to generate html
103
- end
104
- end
@@ -1,49 +0,0 @@
1
- shared_examples_for 'the nav helper' do
2
- all_tests_pass_with 'no nav options'
3
- all_tests_pass_with 'extra nav options'
4
- all_tests_pass_with 'the :as nav option'
5
- all_tests_pass_with 'the :layout nav option'
6
- all_tests_pass_with 'the nav wrapped in navbar'
7
- end
8
-
9
- #--
10
-
11
- shared_examples_for 'no nav options' do
12
- specify 'creates a <ul> element with the "tablist" role' do
13
- html = '<ul class="nav nav-tabs" role="tablist">content</ul>'
14
- expect(:nav).to generate html
15
- end
16
- end
17
-
18
- shared_examples_for 'extra nav options' do
19
- specify 'passes the options to the <ul> element' do
20
- options = {class: 'important', data: {value: 1}, id: 'my-alert'}
21
- html = '<ul class="important nav nav-tabs" data-value="1" id="my-alert" role="tablist">content</ul>'
22
- expect(nav: options).to generate html
23
- end
24
- end
25
-
26
- shared_examples_for 'the :as nav option' do
27
- Bh::Nav.styles.each do |style, style_class|
28
- specify %Q{set to :#{context}, sets the class "#{style_class}"} do
29
- html = %r{<ul class="nav #{style_class}"}
30
- expect(nav: {as: style}).to generate html
31
- end
32
- end
33
- end
34
-
35
- shared_examples_for 'the :layout nav option' do
36
- Bh::Nav.layouts.each do |layout, layout_class|
37
- specify %Q{set to :#{layout}, adds the class "#{layout_class}"} do
38
- html = %r{<ul class="nav nav-tabs #{layout_class}"}
39
- expect(nav: {layout: layout}).to generate html
40
- end
41
- end
42
- end
43
-
44
- shared_examples_for 'the nav wrapped in navbar' do
45
- specify 'creates a <ul> element with the "navbar-nav" class' do
46
- html = '<ul class="nav navbar-nav">content</ul>'
47
- bh.navbar { expect(:nav).to generate html }
48
- end
49
- end
@@ -1,63 +0,0 @@
1
- shared_examples_for 'the navbar helper' do
2
- all_tests_pass_with 'no navbar options'
3
- all_tests_pass_with 'the :fluid navbar option'
4
- all_tests_pass_with 'the :inverted navbar option'
5
- all_tests_pass_with 'the :position navbar option'
6
- all_tests_pass_with 'the :padding navbar option'
7
- end
8
-
9
- #--
10
-
11
- shared_examples_for 'no navbar options' do
12
- specify 'creates a <nav> element with a nested container' do
13
- html = <<-EOT.strip_heredoc.strip
14
- <nav class="navbar navbar-default" role="navigation">
15
- <div class="container">
16
- content
17
- </div>
18
- </nav>
19
- EOT
20
- expect(:navbar).to generate html
21
- end
22
- end
23
-
24
- shared_examples_for 'the :fluid navbar option' do
25
- Bh::Navbar.layouts.each do |value, fluid_class|
26
- specify %Q{set to #{value}, sets the class "#{fluid_class}"} do
27
- html = %r{<div class="#{fluid_class}">}
28
- expect(navbar: {fluid: value}).to generate html
29
- end
30
- end
31
- end
32
-
33
- shared_examples_for 'the :inverted navbar option' do
34
- Bh::Navbar.styles.each do |value, inverted_class|
35
- specify %Q{set to #{value}, sets the class "#{inverted_class}"} do
36
- html = %r{<nav class="navbar #{inverted_class}"}
37
- expect(navbar: {inverted: value}).to generate html
38
- end
39
- end
40
- end
41
-
42
- shared_examples_for 'the :position navbar option' do
43
- Bh::Navbar.positions.each do |position, position_class|
44
- specify %Q{set to #{position}, sets the class "#{position_class}"} do
45
- html = %r{<nav class="navbar navbar-default #{position_class}"}
46
- expect(navbar: {position: position}).to generate html
47
- end
48
- end
49
- end
50
-
51
- shared_examples_for 'the :padding navbar option' do
52
- [:top, :bottom].each do |position|
53
- specify %Q{set to a value, uses that value for #{position} position} do
54
- html = %r{<style>body {padding-#{position}: 100px}</style>}m
55
- expect(navbar: {position: position, padding: 100}).to generate html
56
- end
57
-
58
- specify %Q{not set, uses a default value of 70px for #{position} position} do
59
- html = %r{<style>body {padding-#{position}: 70px}</style>}m
60
- expect(navbar: {position: position}).to generate html
61
- end
62
- end
63
- end