bh 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/CHANGELOG.md +19 -0
  4. data/README.md +51 -18
  5. data/bh.gemspec +13 -9
  6. data/examples/middleman/.gitignore +18 -0
  7. data/examples/middleman/Gemfile +6 -0
  8. data/examples/middleman/config.rb +1 -0
  9. data/examples/middleman/source/index.html.erb +158 -0
  10. data/examples/padrino/Gemfile +9 -0
  11. data/examples/padrino/app/app.rb +16 -0
  12. data/examples/padrino/app/views/index.html.erb +155 -0
  13. data/examples/padrino/config.ru +5 -0
  14. data/examples/padrino/config/apps.rb +5 -0
  15. data/examples/padrino/config/boot.rb +8 -0
  16. data/examples/rails/.gitignore +12 -0
  17. data/examples/rails/Gemfile +5 -0
  18. data/examples/rails/app/controllers/application_controller.rb +6 -0
  19. data/examples/rails/app/controllers/users_controller.rb +2 -0
  20. data/examples/rails/app/models/user.rb +15 -0
  21. data/examples/rails/app/views/application/index.html.erb +160 -0
  22. data/examples/rails/bin/rails +4 -0
  23. data/examples/rails/config.ru +4 -0
  24. data/examples/rails/config/application.rb +12 -0
  25. data/examples/rails/config/boot.rb +3 -0
  26. data/examples/rails/config/environment.rb +5 -0
  27. data/examples/rails/config/environments/development.rb +7 -0
  28. data/examples/rails/config/routes.rb +4 -0
  29. data/examples/rails/config/secrets.yml +22 -0
  30. data/examples/rails/log/.keep +0 -0
  31. data/gemfiles/Gemfile.rails-3.x +2 -0
  32. data/gemfiles/Gemfile.rails-4.x +2 -0
  33. data/lib/bh.rb +15 -4
  34. data/lib/bh/classes/alert_box.rb +35 -0
  35. data/lib/bh/classes/base.rb +125 -0
  36. data/lib/bh/classes/button.rb +58 -0
  37. data/lib/bh/classes/button_to.rb +33 -0
  38. data/lib/bh/classes/cdn.rb +35 -0
  39. data/lib/bh/classes/dropdown.rb +56 -0
  40. data/lib/bh/classes/icon.rb +34 -0
  41. data/lib/bh/classes/link_to.rb +22 -0
  42. data/lib/bh/classes/modal.rb +68 -0
  43. data/lib/bh/classes/nav.rb +37 -0
  44. data/lib/bh/classes/navbar.rb +78 -0
  45. data/lib/bh/classes/panel.rb +72 -0
  46. data/lib/bh/classes/panel_row.rb +13 -0
  47. data/lib/bh/classes/progress_bar.rb +89 -0
  48. data/lib/bh/classes/stack.rb +19 -0
  49. data/lib/bh/classes/vertical.rb +27 -0
  50. data/lib/bh/core_ext/middleman.rb +24 -0
  51. data/lib/bh/core_ext/padrino.rb +25 -0
  52. data/lib/bh/core_ext/rails/base_helper.rb +21 -0
  53. data/lib/bh/{helpers → core_ext/rails}/form/base_helper.rb +3 -1
  54. data/lib/bh/{helpers → core_ext/rails}/form/check_box_helper.rb +1 -1
  55. data/lib/bh/{helpers → core_ext/rails}/form/field_helper.rb +1 -1
  56. data/lib/bh/{helpers → core_ext/rails}/form/fields_for_helper.rb +1 -1
  57. data/lib/bh/{helpers → core_ext/rails}/form/fieldset_helper.rb +1 -1
  58. data/lib/bh/{helpers → core_ext/rails}/form/file_field_helper.rb +1 -1
  59. data/lib/bh/{helpers → core_ext/rails}/form/legend_helper.rb +1 -1
  60. data/lib/bh/{helpers → core_ext/rails}/form/radio_button_helper.rb +1 -1
  61. data/lib/bh/{helpers → core_ext/rails}/form/select_helper.rb +1 -1
  62. data/lib/bh/{helpers → core_ext/rails}/form/static_control_helper.rb +1 -1
  63. data/lib/bh/{helpers → core_ext/rails}/form/submit_helper.rb +1 -1
  64. data/lib/bh/{form_builders → core_ext/rails}/form_builder.rb +11 -10
  65. data/lib/bh/core_ext/rails/form_for_helper.rb +32 -0
  66. data/lib/bh/core_ext/railtie.rb +27 -0
  67. data/lib/bh/helpers/alert_box_helper.rb +40 -0
  68. data/lib/bh/helpers/button_helper.rb +35 -58
  69. data/lib/bh/helpers/button_to_helper.rb +48 -10
  70. data/lib/bh/helpers/cdn_helper.rb +11 -35
  71. data/lib/bh/helpers/dropdown_helper.rb +29 -62
  72. data/lib/bh/helpers/glyphicon_helper.rb +7 -13
  73. data/lib/bh/helpers/horizontal_helper.rb +35 -0
  74. data/lib/bh/helpers/icon_helper.rb +15 -29
  75. data/lib/bh/helpers/link_to_helper.rb +52 -41
  76. data/lib/bh/helpers/modal_helper.rb +49 -79
  77. data/lib/bh/helpers/nav_helper.rb +25 -40
  78. data/lib/bh/helpers/navbar_helper.rb +36 -170
  79. data/lib/bh/helpers/panel_helper.rb +45 -72
  80. data/lib/bh/helpers/panel_row_helper.rb +20 -38
  81. data/lib/bh/helpers/progress_bar_helper.rb +48 -59
  82. data/lib/bh/helpers/vertical_helper.rb +33 -0
  83. data/lib/bh/version.rb +1 -1
  84. data/lib/bh/views/bh/_alert_dismiss_button.html +4 -0
  85. data/lib/bh/views/bh/_dropdown.html.erb +5 -5
  86. data/lib/bh/views/bh/_dropdown_split.html.erb +5 -5
  87. data/lib/bh/views/bh/_modal.html.erb +5 -8
  88. data/lib/bh/views/bh/_navbar.html.erb +5 -0
  89. data/spec/padrino/button_to_helper.rb +35 -0
  90. data/spec/padrino_spec.rb +28 -0
  91. data/spec/rails/button_to_helper.rb +31 -0
  92. data/spec/{helpers → rails}/form/check_box_helper_spec.rb +3 -3
  93. data/spec/{helpers → rails}/form/field_helper_spec.rb +3 -3
  94. data/spec/{helpers → rails}/form/fields_for_helper_spec.rb +3 -3
  95. data/spec/{helpers → rails}/form/fieldset_helper_spec.rb +3 -3
  96. data/spec/{helpers → rails}/form/file_field_helper_spec.rb +3 -3
  97. data/spec/{helpers → rails}/form/legend_helper_spec.rb +3 -3
  98. data/spec/{helpers → rails}/form/radio_button_helper_spec.rb +3 -3
  99. data/spec/{helpers → rails}/form/select_helper_spec.rb +3 -3
  100. data/spec/{helpers → rails}/form/static_control_helper_spec.rb +3 -3
  101. data/spec/{helpers → rails}/form/submit_helper_spec.rb +3 -3
  102. data/spec/{helpers → rails}/form_for_helper_spec.rb +3 -3
  103. data/spec/rails_helper.rb +25 -0
  104. data/spec/rails_spec.rb +28 -0
  105. data/spec/shared/alert_box_helper.rb +62 -0
  106. data/spec/shared/button_helper.rb +52 -0
  107. data/spec/shared/button_to_helper.rb +42 -0
  108. data/spec/shared/cdn_helper.rb +36 -0
  109. data/spec/shared/dropdown_helper.rb +112 -0
  110. data/spec/shared/glyphicon_helper.rb +21 -0
  111. data/spec/shared/horizontal_helper.rb +37 -0
  112. data/spec/shared/icon_helper.rb +31 -0
  113. data/spec/shared/link_to_helper.rb +62 -0
  114. data/spec/shared/modal_helper.rb +104 -0
  115. data/spec/shared/nav_helper.rb +49 -0
  116. data/spec/shared/navbar_helper.rb +63 -0
  117. data/spec/shared/panel_helper.rb +76 -0
  118. data/spec/shared/panel_row_helper.rb +21 -0
  119. data/spec/shared/progress_bar_helper.rb +103 -0
  120. data/spec/shared/vertical_helper.rb +43 -0
  121. data/spec/spec_helper.rb +6 -29
  122. data/spec/support/matchers.rb +38 -0
  123. data/spec/support/padrino.rb +33 -0
  124. data/spec/support/rails.rb +27 -0
  125. metadata +183 -94
  126. data/config.rb +0 -6
  127. data/lib/bh/helpers/alert_helper.rb +0 -77
  128. data/lib/bh/helpers/base_helper.rb +0 -39
  129. data/lib/bh/helpers/form_for_helper.rb +0 -30
  130. data/lib/bh/middleman.rb +0 -39
  131. data/lib/bh/railtie.rb +0 -42
  132. data/spec/dummy/index.html.erb +0 -60
  133. data/spec/dummy/layouts/default.erb +0 -17
  134. data/spec/helpers/alert_helper_spec.rb +0 -84
  135. data/spec/helpers/button_helper_spec.rb +0 -100
  136. data/spec/helpers/button_to_helper_spec.rb +0 -25
  137. data/spec/helpers/cdn_helper_spec.rb +0 -100
  138. data/spec/helpers/dropdown_helper_spec.rb +0 -146
  139. data/spec/helpers/glyphicon_helper_spec.rb +0 -21
  140. data/spec/helpers/icon_helper_spec.rb +0 -45
  141. data/spec/helpers/link_to_helper_spec.rb +0 -124
  142. data/spec/helpers/modal_helper_spec.rb +0 -133
  143. data/spec/helpers/nav_helper_spec.rb +0 -53
  144. data/spec/helpers/navbar_helper_spec.rb +0 -194
  145. data/spec/helpers/panel_helper_spec.rb +0 -95
  146. data/spec/helpers/panel_row_helper_spec.rb +0 -27
  147. data/spec/helpers/progress_bar_helper_spec.rb +0 -114
@@ -1,133 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'spec_helper'
4
- require 'action_dispatch'
5
- require 'bh/helpers/modal_helper'
6
- include Bh::ModalHelper
7
-
8
- describe 'modal' do
9
- let(:views_folder) { File.expand_path('../../../lib/bh/views', __FILE__) }
10
- let(:lookup_context) { ActionView::LookupContext.new views_folder }
11
- let(:view_renderer) { ActionView::Renderer.new lookup_context }
12
- describe 'accepts as parameters:' do
13
- let(:behave) { include 'content' }
14
-
15
- specify 'a string (content)' do
16
- expect(modal 'content').to behave
17
- end
18
-
19
- specify 'a hash (options)' do
20
- expect(modal body: 'content').to behave
21
- end
22
-
23
- specify 'a block (content)' do
24
- expect(modal { 'content' }).to behave
25
- end
26
-
27
- specify 'a string (content) + a hash (options)' do
28
- expect(modal 'content', context: :danger).to behave
29
- end
30
-
31
- specify 'a hash (options) + a block (content)' do
32
- expect(modal(context: :danger) { 'content' }).to behave
33
- end
34
- end
35
-
36
- describe 'with the :button option' do
37
- let(:html) { modal 'content', button: button_options }
38
-
39
- describe 'with the :context option' do
40
- let(:button_options) { {context: context} }
41
-
42
- describe 'set to :primary, shows a "primary" toggle button' do
43
- let(:context) { :primary }
44
- it { expect(html).to include 'btn-primary' }
45
- end
46
-
47
- describe 'set to :success, shows a "success" toggle button' do
48
- let(:context) { :success }
49
- it { expect(html).to include 'btn-success' }
50
- end
51
-
52
- describe 'set to :info, shows a "info" toggle button' do
53
- let(:context) { :info }
54
- it { expect(html).to include 'btn-info' }
55
- end
56
-
57
- describe 'set to :warning, shows a "warning" toggle button' do
58
- let(:context) { :warning }
59
- it { expect(html).to include 'btn-warning' }
60
- end
61
-
62
- describe 'set to :danger, shows a "danger" toggle button' do
63
- let(:context) { :danger }
64
- it { expect(html).to include 'btn-danger' }
65
- end
66
-
67
- describe 'set to :link, shows a "link" toggle button' do
68
- let(:context) { :link }
69
- it { expect(html).to include 'btn-link' }
70
- end
71
-
72
- describe 'set to any other value, shows a "default" toggle button' do
73
- let(:context) { :unknown }
74
- it { expect(html).to include 'btn-default' }
75
- end
76
- end
77
-
78
- describe 'without the :context option, shows a "default" toggle button' do
79
- let(:button_options) { {} }
80
- it { expect(html).to include 'btn-default' }
81
- end
82
-
83
- describe 'with the :size option' do
84
- let(:button_options) { {size: size} }
85
-
86
- describe 'set to :large, shows a large toggle button' do
87
- let(:size) { :large }
88
- it { expect(html).to include 'btn-lg' }
89
- end
90
-
91
- describe 'set to :small, shows a small toggle button' do
92
- let(:size) { :small }
93
- it { expect(html).to include 'btn-sm' }
94
- end
95
-
96
- describe 'set to :extra_small, shows an extra-small toggle button' do
97
- let(:size) { :extra_small }
98
- it { expect(html).to include 'btn-xs' }
99
- end
100
- end
101
-
102
- describe 'with the :caption option, shows the caption on the button' do
103
- let(:button_options) { {caption: 'Call to action'} }
104
- it { expect(html).to include 'Call to action' }
105
- end
106
- end
107
-
108
- describe 'with the :size option' do
109
- let(:html) { modal 'content', size: size }
110
-
111
- describe 'set to :large, shows a large modal' do
112
- let(:size) { :large }
113
- it { expect(html).to include 'modal-dialog modal-lg' }
114
- end
115
-
116
- describe 'set to :small, shows a small modal' do
117
- let(:size) { :small }
118
- it { expect(html).to include 'modal-dialog modal-sm' }
119
- end
120
- end
121
-
122
- describe 'with the :body option' do
123
- specify 'includes its value in the modal body' do
124
- expect(modal body: 'Your profile was updated', title: 'Profile').to include '<div class="modal-body">Your profile was updated</div>'
125
- end
126
- end
127
-
128
- describe 'with the :title option' do
129
- specify 'includes its value as a title in the modal heading' do
130
- expect(modal 'content', title: 'Profile').to include 'Profile</h4>'
131
- end
132
- end
133
- end
@@ -1,53 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'spec_helper'
4
- require 'bh/helpers/nav_helper'
5
- require 'bh/helpers/navbar_helper'
6
-
7
- include Bh::NavHelper
8
- include Bh::NavbarHelper
9
-
10
- describe 'nav' do
11
- let(:html) { nav options, &block }
12
- let(:block) { Proc.new {} }
13
- let(:options) { {} }
14
-
15
- describe 'with the :as option' do
16
- specify 'not set, shows a "tabs" nav' do
17
- expect(html).to include 'ul class="nav nav-tabs" role="tablist"'
18
- end
19
-
20
- context 'set to :tabs, shows a "tabs" nav' do
21
- let(:options) { {as: :tabs} }
22
- it { expect(html).to include 'ul class="nav nav-tabs"' }
23
- end
24
-
25
- context 'set to :pills, shows a "tabs" nav' do
26
- let(:options) { {as: :pills} }
27
- it { expect(html).to include 'ul class="nav nav-pills"' }
28
- end
29
- end
30
-
31
- describe 'with the :layout option' do
32
- specify 'not set, does not set a layout' do
33
- expect(html).to include 'ul class="nav nav-tabs" role="tablist"'
34
- end
35
-
36
- context 'set to :justified, shows a "justified" nav' do
37
- let(:options) { {layout: :justified} }
38
- it { expect(html).to include 'nav-justified' }
39
- end
40
-
41
- context 'set to :stacked, shows a "stacked" nav' do
42
- let(:options) { {layout: :stacked} }
43
- it { expect(html).to include 'nav-stacked' }
44
- end
45
- end
46
-
47
- describe 'within a navbar' do
48
- let(:html) { navbar { nav options, &block } }
49
- specify 'applies roles and classes specific to navbar' do
50
- expect(html).to include 'ul class="nav navbar-nav">'
51
- end
52
- end
53
- end
@@ -1,194 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'spec_helper'
4
- require 'bh/helpers/navbar_helper'
5
- require 'bh/helpers/nav_helper'
6
-
7
- include Bh::NavbarHelper
8
- include Bh::NavHelper
9
-
10
- describe 'navbar' do
11
- let(:html) { navbar options, &block }
12
- let(:block) { Proc.new {} }
13
- let(:options) { {} }
14
-
15
- specify 'applies Bootstrap attributes to the navbar' do
16
- expect(html).to match %r{<nav.+? role="navigation">}
17
- end
18
-
19
- describe 'with the :fluid option' do
20
- specify 'not set, adds a "container" div to the navbar' do
21
- expect(html).to include '<div class="container">'
22
- end
23
-
24
- context 'set to false, adds a "container" div to the navbar' do
25
- let(:options) { {fluid: false} }
26
- it { expect(html).to include '<div class="container">' }
27
- end
28
-
29
- context 'set to true, adds a "container-fluid" div to the navbar' do
30
- let(:options) { {fluid: true} }
31
- it { expect(html).to include '<div class="container-fluid">' }
32
- end
33
- end
34
-
35
- describe 'with the :inverted option' do
36
- specify 'not set, shows a "default" navbar' do
37
- expect(html).to include 'nav class="navbar navbar-default"'
38
- end
39
-
40
- context 'set to false, shows a "default" nav' do
41
- let(:options) { {inverted: false} }
42
- it { expect(html).to include 'nav class="navbar navbar-default"' }
43
- end
44
-
45
- context 'set to true, shows an "inverse" nav' do
46
- let(:options) { {inverted: true} }
47
- it { expect(html).to include 'nav class="navbar navbar-inverse"' }
48
- end
49
- end
50
-
51
- describe 'with the :position option' do
52
- specify 'not set, does not set a navbar position' do
53
- expect(html).to include 'nav class="navbar navbar-default"'
54
- end
55
-
56
- context 'set to :static, shows the navbar at the top (static) without padding' do
57
- let(:options) { {position: :static} }
58
- it { expect(html).to include 'nav class="navbar navbar-default navbar-static-top"' }
59
- it { expect(html).not_to include 'padding' }
60
- end
61
-
62
- context 'set to :static_top, shows the navbar at the top (static) without padding' do
63
- let(:options) { {position: :static_top} }
64
- it { expect(html).to include 'nav class="navbar navbar-default navbar-static-top"' }
65
- it { expect(html).not_to include 'padding' }
66
- end
67
-
68
- context 'set to :top, shows the navbar at the top (fixed)' do
69
- let(:options) { {position: :top} }
70
- it { expect(html).to include 'nav class="navbar navbar-default navbar-fixed-top"' }
71
-
72
- context 'with the :padding' do
73
- specify 'not set, adds 70px to the top padding of the body' do
74
- expect(html).to include '<style>body {padding-top: 70px}</style>'
75
- end
76
-
77
- context 'set to a value, adds those pixels to the top padding of the body' do
78
- let(:options) { {position: :top, padding: 100} }
79
-
80
- it { expect(html).to include '<style>body {padding-top: 100px}</style>' }
81
- end
82
-
83
- context 'set to nil, does not add a top padding to the body' do
84
- let(:options) { {position: :top, padding: nil} }
85
-
86
- it { expect(html).not_to include 'padding' }
87
- end
88
- end
89
- end
90
-
91
- context 'set to :fixed_top, shows the navbar at the top (fixed)' do
92
- let(:options) { {position: :fixed_top} }
93
- it { expect(html).to include 'nav class="navbar navbar-default navbar-fixed-top"' }
94
- end
95
-
96
- context 'set to :bottom, shows the navbar at the bottom (fixed)' do
97
- let(:options) { {position: :bottom} }
98
- it { expect(html).to include 'nav class="navbar navbar-default navbar-fixed-bottom"' }
99
-
100
- context 'with the :padding' do
101
- specify 'not set, adds 70px to the bottom padding of the body' do
102
- expect(html).to include '<style>body {padding-bottom: 70px}</style>'
103
- end
104
-
105
- context 'set to a value, adds those pixels to the bottom padding of the body' do
106
- let(:options) { {position: :bottom, padding: 100} }
107
-
108
- it { expect(html).to include '<style>body {padding-bottom: 100px}</style>' }
109
- end
110
-
111
- context 'set to nil, does not add a bottom padding to the body' do
112
- let(:options) { {position: :bottom, padding: nil} }
113
-
114
- it { expect(html).not_to include 'padding' }
115
- end
116
- end
117
- end
118
-
119
- context 'set to :fixed_bottom, shows the navbar at the bottom (fixed)' do
120
- let(:options) { {position: :fixed_bottom} }
121
- it { expect(html).to include 'nav class="navbar navbar-default navbar-fixed-bottom"' }
122
- end
123
- end
124
- end
125
-
126
- describe 'vertical' do
127
- describe 'accepts as parameters:' do
128
- let(:behave) { be_a String }
129
-
130
- specify 'a string (content)' do
131
- expect(vertical 'content').to behave
132
- end
133
-
134
- specify 'a block (content)' do
135
- expect(vertical { 'content' }).to behave
136
- end
137
-
138
- specify 'a string (content) + a hash (options)' do
139
- expect(vertical 'content', class: :important).to behave
140
- end
141
-
142
- specify 'a hash (options) + a block (content)' do
143
- expect(vertical(class: :important) { 'content' }).to behave
144
- end
145
- end
146
-
147
- describe 'adds a toggle button and bars' do
148
- let(:html) { vertical 'content' }
149
- it { expect(html).to match %r{<button class="navbar-toggle" data-target="#.+?" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span>\n<span class="icon-bar"></span>\n<span class="icon-bar"></span>\n<span class="icon-bar"></span></button}m }
150
- end
151
- end
152
-
153
- describe 'horizontal' do
154
- describe 'accepts as parameters:' do
155
- let(:behave) { be_a String }
156
-
157
- specify 'a string (content)' do
158
- expect(horizontal 'content').to behave
159
- end
160
-
161
- specify 'a block (content)' do
162
- expect(horizontal { 'content' }).to behave
163
- end
164
-
165
- specify 'a string (content) + a hash (options)' do
166
- expect(horizontal 'content', class: :important).to behave
167
- end
168
-
169
- specify 'a hash (options) + a block (content)' do
170
- expect(horizontal(class: :important) { 'content' }).to behave
171
- end
172
- end
173
-
174
- describe 'adds a collapsable div' do
175
- let(:html) { horizontal 'content' }
176
- it { expect(html).to match %r{<div class="collapse navbar-collapse" id=".+?">content</div>} }
177
- end
178
- end
179
-
180
- describe 'multiple navbars' do
181
- let(:navbar_1) { navbar inverted: true do
182
- safe_join [vertical(link_to 'Home', '/'), horizontal(content_tag :p, '')]
183
- end }
184
- let(:navbar_2) { navbar position: :top do
185
- safe_join [vertical(content_tag :p, ''), horizontal(link_to 'Home', '/')]
186
- end }
187
- let(:html) { safe_join [navbar_1, navbar_2], "\n"}
188
-
189
- specify 'toggle their own horizontal part when clicking on vertical' do
190
- navbar_ids = html.scan %r{<nav.+?data-target="#(.+?)".+?id="(\1)".+?</nav>}m
191
- expect(navbar_ids.size).to eq 2
192
- expect(navbar_ids.uniq.size).to eq 2
193
- end
194
- end
@@ -1,95 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'spec_helper'
4
- require 'bh/helpers/panel_helper'
5
- include Bh::PanelHelper
6
-
7
- describe 'panel' do
8
- describe 'accepts as parameters:' do
9
- let(:behave) { include 'content' }
10
-
11
- specify 'a string (content)' do
12
- expect(panel 'content').to behave
13
- end
14
-
15
- specify 'a hash (options)' do
16
- expect(panel body: 'content').to behave
17
- end
18
-
19
- specify 'a block (content)' do
20
- expect(panel { 'content' }).to behave
21
- end
22
-
23
- specify 'a string (content) + a hash (options)' do
24
- expect(panel 'content', context: :danger).to behave
25
- end
26
-
27
- specify 'a hash (options) + a block (content)' do
28
- expect(panel(context: :danger) { 'content' }).to behave
29
- end
30
- end
31
-
32
- describe 'with the :context option' do
33
- specify 'set to :default, shows a "default" panel' do
34
- expect(panel 'content', context: :default).to include 'panel-default'
35
- end
36
-
37
- specify 'set to :primary, shows a "primary" panel' do
38
- expect(panel 'content', context: :primary).to include 'panel-primary'
39
- end
40
-
41
- specify 'set to :success, shows a "success" panel' do
42
- expect(panel 'content', context: :success).to include 'panel-success'
43
- end
44
-
45
- specify 'set to :info, shows a "info" panel' do
46
- expect(panel 'content', context: :info).to include 'panel-info'
47
- end
48
-
49
- specify 'set to :warning, shows a "warning" panel' do
50
- expect(panel 'content', context: :warning).to include 'panel-warning'
51
- end
52
-
53
- specify 'set to :danger, shows a "danger" panel' do
54
- expect(panel 'content', context: :danger).to include 'panel-danger'
55
- end
56
-
57
- specify 'set to any other value, shows an "default" panel' do
58
- expect(panel 'content', context: :unknown).to include 'panel-default'
59
- end
60
-
61
- specify 'not set, shows an "default" panel' do
62
- expect(panel 'content').to include 'panel-default'
63
- end
64
- end
65
-
66
- describe 'with the :body option' do
67
- specify 'includes its value in the panel body' do
68
- expect(panel 'content', body: 'Your profile was updated', title: 'Profile').to include '<div class="panel-body">Your profile was updated</div>'
69
- end
70
- end
71
-
72
- describe 'with the :heading option' do
73
- specify 'includes its value in the panel heading' do
74
- expect(panel 'content', heading: 'Profile').to include '<div class="panel-heading">Profile</div>'
75
- end
76
- end
77
-
78
- describe 'with the :title option' do
79
- specify 'includes its value as a title in the panel heading' do
80
- expect(panel 'content', title: 'Profile').to include '<div class="panel-heading"><h3 class="panel-title">Profile</h3></div>'
81
- end
82
- end
83
-
84
- describe 'without the :heading or the :title option' do
85
- specify 'does not include the panel heading' do
86
- expect(panel 'content').not_to include 'panel-heading'
87
- end
88
- end
89
-
90
- describe 'with the :tag option' do
91
- specify 'uses the specified tag rather than DIV' do
92
- expect(panel 'content', tag: :aside).to include '<aside class="panel panel-default">'
93
- end
94
- end
95
- end