bh 1.0.1 → 1.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.yardopts +2 -0
- data/CHANGELOG.md +9 -0
- data/README.md +8 -4
- data/bh.gemspec +3 -0
- data/config.rb +6 -0
- data/lib/bh.rb +1 -0
- data/lib/bh/helpers/alert_helper.rb +2 -6
- data/lib/bh/helpers/base_helper.rb +14 -0
- data/lib/bh/helpers/button_helper.rb +63 -0
- data/lib/bh/helpers/cdn_helper.rb +26 -6
- data/lib/bh/helpers/dropdown_helper.rb +82 -0
- data/lib/bh/helpers/form/fields_for_helper.rb +3 -1
- data/lib/bh/helpers/glyphicon_helper.rb +7 -7
- data/lib/bh/helpers/icon_helper.rb +41 -0
- data/lib/bh/helpers/link_to_helper.rb +21 -5
- data/lib/bh/helpers/modal_helper.rb +2 -9
- data/lib/bh/helpers/panel_helper.rb +2 -8
- data/lib/bh/helpers/progress_bar_helper.rb +66 -0
- data/lib/bh/middleman.rb +39 -0
- data/lib/bh/railtie.rb +8 -0
- data/lib/bh/version.rb +1 -1
- data/lib/bh/views/bh/_dropdown.html.erb +9 -0
- data/lib/bh/views/bh/_dropdown_split.html.erb +10 -0
- data/spec/dummy/index.html.erb +60 -0
- data/spec/dummy/layouts/default.erb +17 -0
- data/spec/helpers/button_helper_spec.rb +100 -0
- data/spec/helpers/cdn_helper_spec.rb +25 -1
- data/spec/helpers/dropdown_helper_spec.rb +146 -0
- data/spec/helpers/form/fields_for_helper_spec.rb +30 -14
- data/spec/helpers/icon_helper_spec.rb +45 -0
- data/spec/helpers/link_to_helper_spec.rb +24 -0
- data/spec/helpers/progress_bar_helper_spec.rb +114 -0
- metadata +37 -2
@@ -58,15 +58,8 @@ module Bh
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def button_class(options = {})
|
61
|
-
|
62
|
-
|
63
|
-
when 'success' then :success
|
64
|
-
when 'info' then :info
|
65
|
-
when 'warning' then :warning
|
66
|
-
when 'danger' then :danger
|
67
|
-
when 'link' then :link
|
68
|
-
else 'default'
|
69
|
-
end
|
61
|
+
valid_contexts = %w(primary success info warning danger link)
|
62
|
+
context = context_for options[:context], valid: valid_contexts
|
70
63
|
|
71
64
|
size = case options[:size].to_s
|
72
65
|
when 'lg', 'large' then 'btn-lg'
|
@@ -56,14 +56,8 @@ module Bh
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def panel_class(context = nil)
|
59
|
-
|
60
|
-
|
61
|
-
when 'success' then :success
|
62
|
-
when 'info' then :info
|
63
|
-
when 'warning' then :warning
|
64
|
-
when 'danger' then :danger
|
65
|
-
else 'default'
|
66
|
-
end
|
59
|
+
valid_contexts = %w(primary success info warning danger)
|
60
|
+
context = context_for context, valid: valid_contexts
|
67
61
|
"panel panel-#{context}"
|
68
62
|
end
|
69
63
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'bh/helpers/base_helper'
|
2
|
+
|
3
|
+
module Bh
|
4
|
+
# Provides methods to include progress bars.
|
5
|
+
# @see http://getbootstrap.com/components/#progress
|
6
|
+
module ProgressBarHelper
|
7
|
+
include BaseHelper
|
8
|
+
|
9
|
+
# Returns an HTML block tag that follows the Bootstrap documentation
|
10
|
+
# on how to display *progress bars*.
|
11
|
+
# @param [Hash, Array<Hash>] options the display options for the progress
|
12
|
+
# bar(s). When options is an Array, a group of stacked progress bars
|
13
|
+
# is displayed, with the options specified in each item of the array.
|
14
|
+
# @option options [Boolean, #to_s] :label (false) the label to display
|
15
|
+
# on top of the progress bar. If set to false, the label is hidden. If
|
16
|
+
# set to true, the label is generated from the percentage value. Any
|
17
|
+
# other provided value is used directly as the label.
|
18
|
+
# @option options [Boolean] :striped (false) whether to display a striped
|
19
|
+
# version of the progress bar (rather than solid color).
|
20
|
+
# @option options [Boolean] :animated (false) whether to display an
|
21
|
+
# animated version of the progress bar (rather than solid color).
|
22
|
+
# @option options [#to_s] :context (:default) the contextual alternative to
|
23
|
+
# apply to the progress bar depending on its importance. Can be
|
24
|
+
# `:success`, `:info`, `:warning` or `:danger`.
|
25
|
+
def progress_bar(options = {})
|
26
|
+
content_tag :div, class: :progress do
|
27
|
+
safe_join Array.wrap(options).map{|bar| progress_bar_string bar}, "\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def progress_bar_string(options = {})
|
34
|
+
percentage = options.fetch :percentage, 0
|
35
|
+
|
36
|
+
attributes = {}.tap do |attrs|
|
37
|
+
attrs[:class] = progress_bar_class(options)
|
38
|
+
attrs[:role] = 'progressbar'
|
39
|
+
attrs[:style] = "width: #{percentage}%"
|
40
|
+
attrs['aria-valuenow'] = percentage
|
41
|
+
attrs['aria-valuemin'] = 0
|
42
|
+
attrs['aria-valuemax'] = 100
|
43
|
+
end
|
44
|
+
|
45
|
+
content_tag :div, progress_bar_label(percentage, options), attributes
|
46
|
+
end
|
47
|
+
|
48
|
+
def progress_bar_label(percentage, options = {})
|
49
|
+
text = "#{percentage}%#{" (#{options[:context]})" if options[:context]}"
|
50
|
+
case options.fetch(:label, false)
|
51
|
+
when true then text
|
52
|
+
when false then content_tag(:span, text, class: 'sr-only')
|
53
|
+
else options[:label]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def progress_bar_class(options = {})
|
58
|
+
valid_contexts = %w(success info warning danger)
|
59
|
+
context = context_for options[:context], valid: valid_contexts
|
60
|
+
context = context.in?(valid_contexts) ? "progress-bar-#{context}" : nil
|
61
|
+
striped = 'progress-bar-striped' if options[:striped]
|
62
|
+
animated = 'progress-bar-striped active' if options[:animated]
|
63
|
+
['progress-bar', context, striped, animated].compact.join ' '
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/bh/middleman.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'bh/helpers/alert_helper'
|
2
|
+
require 'bh/helpers/button_helper'
|
3
|
+
require 'bh/helpers/button_to_helper'
|
4
|
+
require 'bh/helpers/cdn_helper'
|
5
|
+
require 'bh/helpers/dropdown_helper'
|
6
|
+
require 'bh/helpers/form_for_helper'
|
7
|
+
require 'bh/helpers/glyphicon_helper'
|
8
|
+
require 'bh/helpers/icon_helper'
|
9
|
+
require 'bh/helpers/link_to_helper'
|
10
|
+
require 'bh/helpers/modal_helper'
|
11
|
+
require 'bh/helpers/nav_helper'
|
12
|
+
require 'bh/helpers/navbar_helper'
|
13
|
+
require 'bh/helpers/panel_helper'
|
14
|
+
require 'bh/helpers/panel_row_helper'
|
15
|
+
require 'bh/helpers/progress_bar_helper'
|
16
|
+
|
17
|
+
module Bh
|
18
|
+
class MiddlemanExtension < Middleman::Extension
|
19
|
+
helpers do
|
20
|
+
include AlertHelper
|
21
|
+
include ButtonHelper
|
22
|
+
include ButtonToHelper
|
23
|
+
include CdnHelper
|
24
|
+
include DropdownHelper
|
25
|
+
include FormForHelper
|
26
|
+
include GlyphiconHelper
|
27
|
+
include IconHelper
|
28
|
+
include LinkToHelper
|
29
|
+
include ModalHelper
|
30
|
+
include NavHelper
|
31
|
+
include NavbarHelper
|
32
|
+
include PanelHelper
|
33
|
+
include PanelRowHelper
|
34
|
+
include ProgressBarHelper
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
::Middleman::Extensions.register(:bh, Bh::MiddlemanExtension)
|
data/lib/bh/railtie.rb
CHANGED
@@ -1,29 +1,37 @@
|
|
1
1
|
require 'bh/helpers/alert_helper'
|
2
|
+
require 'bh/helpers/button_helper'
|
2
3
|
require 'bh/helpers/button_to_helper'
|
3
4
|
require 'bh/helpers/cdn_helper'
|
5
|
+
require 'bh/helpers/dropdown_helper'
|
4
6
|
require 'bh/helpers/form_for_helper'
|
5
7
|
require 'bh/helpers/glyphicon_helper'
|
8
|
+
require 'bh/helpers/icon_helper'
|
6
9
|
require 'bh/helpers/link_to_helper'
|
7
10
|
require 'bh/helpers/modal_helper'
|
8
11
|
require 'bh/helpers/nav_helper'
|
9
12
|
require 'bh/helpers/navbar_helper'
|
10
13
|
require 'bh/helpers/panel_helper'
|
11
14
|
require 'bh/helpers/panel_row_helper'
|
15
|
+
require 'bh/helpers/progress_bar_helper'
|
12
16
|
|
13
17
|
module Bh
|
14
18
|
class Railtie < Rails::Railtie
|
15
19
|
initializer 'bh.add_helpers' do
|
16
20
|
ActionView::Base.send :include, AlertHelper
|
21
|
+
ActionView::Base.send :include, ButtonHelper
|
17
22
|
ActionView::Base.send :include, ButtonToHelper
|
18
23
|
ActionView::Base.send :include, CdnHelper
|
24
|
+
ActionView::Base.send :include, DropdownHelper
|
19
25
|
ActionView::Base.send :include, FormForHelper
|
20
26
|
ActionView::Base.send :include, GlyphiconHelper
|
27
|
+
ActionView::Base.send :include, IconHelper
|
21
28
|
ActionView::Base.send :include, LinkToHelper
|
22
29
|
ActionView::Base.send :include, ModalHelper
|
23
30
|
ActionView::Base.send :include, NavHelper
|
24
31
|
ActionView::Base.send :include, NavbarHelper
|
25
32
|
ActionView::Base.send :include, PanelHelper
|
26
33
|
ActionView::Base.send :include, PanelRowHelper
|
34
|
+
ActionView::Base.send :include, ProgressBarHelper
|
27
35
|
end
|
28
36
|
|
29
37
|
initializer 'bh.add_views' do |app|
|
data/lib/bh/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
<div class="<%= div_class %>">
|
2
|
+
<button class="dropdown-toggle <%= button_class %>" type="button" id="label-<%= id %>" data-toggle="dropdown">
|
3
|
+
<%= caption %>
|
4
|
+
<span class="caret"></span>
|
5
|
+
</button>
|
6
|
+
<ul class="<%= list_class %>" role="menu" aria-labelledby="label-<%= id %>">
|
7
|
+
<%= yield %>
|
8
|
+
</ul>
|
9
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="<%= div_class %>">
|
2
|
+
<button type="button" class="<%= button_class %>"><%= caption %></button>
|
3
|
+
<button class="dropdown-toggle <%= button_class %>" type="button" id="label-<%= id %>" data-toggle="dropdown">
|
4
|
+
<span class="caret"></span>
|
5
|
+
<span class="sr-only">Toggle Dropdown</span>
|
6
|
+
</button>
|
7
|
+
<ul class="<%= list_class %>" role="menu" aria-labelledby="label-<%= id %>">
|
8
|
+
<%= yield %>
|
9
|
+
</ul>
|
10
|
+
</div>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
---
|
4
|
+
<!-- Edit the code below to see how code looks in a browser -->
|
5
|
+
<!-- Note that only *a few* helpers are currently supported by Bh+Middleman,
|
6
|
+
so the use of this dummy file is currently limited to the helpers
|
7
|
+
listed below. The plan is to make all the helpers look in Middleman
|
8
|
+
in the future, as they do in Rails. -->
|
9
|
+
<h1>Alerts</h1>
|
10
|
+
|
11
|
+
<%= alert_box 'You accepted the Terms of service.', context: :success, dismissible: true %>
|
12
|
+
<%= alert_box 'You accepted the Terms of service.', context: :info, dismissible: true %>
|
13
|
+
<%= alert_box 'You accepted the Terms of service.', context: :warning, dismissible: true %>
|
14
|
+
<%= alert_box 'You accepted the Terms of service.', context: :danger, dismissible: true %>
|
15
|
+
<%= alert_box 'You accepted the Terms of service.', dismissible: true %>
|
16
|
+
|
17
|
+
|
18
|
+
<p>Alert boxes with HTML content currently not supported in Middleman.</p>
|
19
|
+
|
20
|
+
<h1>Panels</h1>
|
21
|
+
|
22
|
+
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :primary %>
|
23
|
+
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :success %>
|
24
|
+
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :info %>
|
25
|
+
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :warning %>
|
26
|
+
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :danger %>
|
27
|
+
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks' %>
|
28
|
+
|
29
|
+
|
30
|
+
<p>Panels with HTML content currently not supported in Middleman.</p>
|
31
|
+
|
32
|
+
<h1>Panel rows</h1>
|
33
|
+
|
34
|
+
<p>Panel rows currently not supported in Middleman.</p>
|
35
|
+
|
36
|
+
<h1>Modals</h1>
|
37
|
+
|
38
|
+
<p>Modals currently not supported in Middleman.</p>
|
39
|
+
|
40
|
+
<h1>Navs</h1>
|
41
|
+
|
42
|
+
<p>Navs currently not supported in Middleman.</p>
|
43
|
+
|
44
|
+
<h1>Navbars</h1>
|
45
|
+
|
46
|
+
<p>Navbars currently not supported in Middleman.</p>
|
47
|
+
|
48
|
+
<h1>Forms</h1>
|
49
|
+
|
50
|
+
<p>Forms currently not supported in Middleman.</p>
|
51
|
+
|
52
|
+
<h1>Glyphicons</h1>
|
53
|
+
|
54
|
+
<%= icon :zoom_in %>
|
55
|
+
|
56
|
+
<h1>Icons</h1>
|
57
|
+
|
58
|
+
<%= icon :heart %>
|
59
|
+
<%= stylesheet_link_tag font_awesome_css %>
|
60
|
+
<%= icon :heart, library: :font_awesome, class: 'fa-5x' %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<%= stylesheet_link_tag font_awesome_css, bootstrap_css, bootstrap_theme_css %>
|
8
|
+
<title>Bh test page</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div class='container'>
|
12
|
+
<%= yield %>
|
13
|
+
</div>
|
14
|
+
<%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' %>
|
15
|
+
<%= javascript_include_tag bootstrap_js %>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'bh/helpers/button_helper'
|
5
|
+
include Bh::ButtonHelper
|
6
|
+
|
7
|
+
describe 'button' do
|
8
|
+
describe 'accepts as parameters:' do
|
9
|
+
let(:behave) { match %r{^<button class="btn.+?">content</button>} }
|
10
|
+
|
11
|
+
specify 'a string (content)' do
|
12
|
+
expect(button 'content').to behave
|
13
|
+
end
|
14
|
+
|
15
|
+
specify 'a block (content)' do
|
16
|
+
expect(button { 'content' }).to behave
|
17
|
+
end
|
18
|
+
|
19
|
+
specify 'a string (content) + a hash (options)' do
|
20
|
+
expect(button 'content', context: :danger).to behave
|
21
|
+
end
|
22
|
+
|
23
|
+
specify 'a hash (options) + a block (content)' do
|
24
|
+
expect(button(context: :danger) { 'content' }).to behave
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'with the :context option' do
|
29
|
+
let(:html) { button 'content', context: context }
|
30
|
+
|
31
|
+
describe 'set to :primary, shows a "primary" button' do
|
32
|
+
let(:context) { :primary }
|
33
|
+
it { expect(html).to include 'btn-primary' }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'set to :success, shows a "success" button' do
|
37
|
+
let(:context) { :success }
|
38
|
+
it { expect(html).to include 'btn-success' }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'set to :info, shows a "info" button' do
|
42
|
+
let(:context) { :info }
|
43
|
+
it { expect(html).to include 'btn-info' }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'set to :warning, shows a "warning" button' do
|
47
|
+
let(:context) { :warning }
|
48
|
+
it { expect(html).to include 'btn-warning' }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'set to :danger, shows a "danger" button' do
|
52
|
+
let(:context) { :danger }
|
53
|
+
it { expect(html).to include 'btn-danger' }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'set to :link, shows a "link" button' do
|
57
|
+
let(:context) { :link }
|
58
|
+
it { expect(html).to include 'btn-link' }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'set to any other value, shows a "default" button' do
|
62
|
+
let(:context) { :unknown }
|
63
|
+
it { expect(html).to include 'btn-default' }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'without the :context option, shows a "default" button' do
|
68
|
+
let(:html) { button 'content' }
|
69
|
+
it { expect(html).to include 'btn-default' }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'with the :size option' do
|
73
|
+
let(:html) { button 'content', size: size }
|
74
|
+
|
75
|
+
describe 'set to :large, shows a large button' do
|
76
|
+
let(:size) { :large }
|
77
|
+
it { expect(html).to include 'btn-lg' }
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'set to :small, shows a small button' do
|
81
|
+
let(:size) { :small }
|
82
|
+
it { expect(html).to include 'btn-sm' }
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'set to :extra_small, shows an extra-small button' do
|
86
|
+
let(:size) { :extra_small }
|
87
|
+
it { expect(html).to include 'btn-xs' }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
describe 'with the :layout option' do
|
93
|
+
let(:html) { button 'content', layout: layout }
|
94
|
+
|
95
|
+
describe 'set to :block, shows a "block" button' do
|
96
|
+
let(:layout) { :block }
|
97
|
+
it { expect(html).to include 'btn-block' }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -73,4 +73,28 @@ describe 'bootstrap_js' do
|
|
73
73
|
let(:options) { {scheme: :https, version: '3.1.0'} }
|
74
74
|
it{ expect(file).to be }
|
75
75
|
end
|
76
|
-
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'font_awesome_css' do
|
79
|
+
let(:file) { open font_awesome_css(options), ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
80
|
+
|
81
|
+
describe 'with the HTTP scheme, links to an existing file' do
|
82
|
+
let(:options) { {scheme: :http} }
|
83
|
+
it{ expect(file).to be }
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'with the HTTPS scheme, links to an existing file' do
|
87
|
+
let(:options) { {scheme: :https} }
|
88
|
+
it{ expect(file).to be }
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'non-minified, links to an existing file' do
|
92
|
+
let(:options) { {scheme: :http, minified: false} }
|
93
|
+
it{ expect(file).to be }
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'given a legacy version, links to an existing file' do
|
97
|
+
let(:options) { {scheme: :https, version: '3.1.0'} }
|
98
|
+
it{ expect(file).to be }
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'action_dispatch'
|
5
|
+
require 'bh/helpers/dropdown_helper'
|
6
|
+
include Bh::DropdownHelper
|
7
|
+
|
8
|
+
describe 'dropdown' 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
|
+
let(:caption) { 'Menu' }
|
13
|
+
let(:options) { {} }
|
14
|
+
let(:html) { dropdown(caption, options) {} }
|
15
|
+
|
16
|
+
specify 'uses the caption with a caret as the button caption' do
|
17
|
+
expect(html).to match %r{<button .+>.+Menu.+<span class="caret"></span>.+</button>}m
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'with the :groupable option' do
|
21
|
+
specify 'not set, wraps the dropdown in a "btn-group" div' do
|
22
|
+
expect(html).to include '<div class="btn-group">'
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'set to true, wraps the dropdown in a "btn-group" div' do
|
26
|
+
let(:options) { {groupable: true} }
|
27
|
+
it { expect(html).to include '<div class="btn-group">' }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'set to false, wraps the dropdown in a "dropdown" div' do
|
31
|
+
let(:options) { {groupable: false} }
|
32
|
+
it { expect(html).to include '<div class="dropdown">' }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'with the :align option' do
|
37
|
+
specify 'not set, wraps the list in a "dropdown-menu" ul' do
|
38
|
+
expect(html).to include '<ul class="dropdown-menu"'
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'set to :left, wraps the dropdown in a dropdown-menu" ul' do
|
42
|
+
let(:options) { {align: :left} }
|
43
|
+
it { expect(html).to include '<ul class="dropdown-menu"' }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'set to :right, adds the dropdown-menu-right class to the ul' do
|
47
|
+
let(:options) { {align: :right} }
|
48
|
+
it { expect(html).to include '<ul class="dropdown-menu dropdown-menu-right"' }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'with the :direction option' do
|
53
|
+
specify 'not set, uses the default dropdown direction' do
|
54
|
+
expect(html).not_to include 'dropup'
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'set to :down, uses the default dropdown direction' do
|
58
|
+
let(:options) { {direction: :down} }
|
59
|
+
it { expect(html).not_to include 'dropup' }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'set to :up, adds the dropup class to the div' do
|
63
|
+
let(:options) { {direction: :up} }
|
64
|
+
it { expect(html).to include 'dropup' }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'with the :split option' do
|
69
|
+
specify 'not set, uses a single dropdown button' do
|
70
|
+
expect(html).not_to match %r{</button>.+</button}m
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'set to false, uses a single dropdown button' do
|
74
|
+
let(:options) { {split: false} }
|
75
|
+
it { expect(html).not_to match %r{</button>.+</button}m }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'set to true, uses a split dropdown button' do
|
79
|
+
let(:options) { {split: true} }
|
80
|
+
it { expect(html).to match %r{</button>.+</button}m }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'with the :context option' do
|
85
|
+
let(:options) { {context: context} }
|
86
|
+
|
87
|
+
describe 'set to :primary, shows a "primary" dropdown button' do
|
88
|
+
let(:context) { :primary }
|
89
|
+
it { expect(html).to include 'btn-primary' }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'set to :success, shows a "success" dropdown button' do
|
93
|
+
let(:context) { :success }
|
94
|
+
it { expect(html).to include 'btn-success' }
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'set to :info, shows a "info" dropdown button' do
|
98
|
+
let(:context) { :info }
|
99
|
+
it { expect(html).to include 'btn-info' }
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'set to :warning, shows a "warning" dropdown button' do
|
103
|
+
let(:context) { :warning }
|
104
|
+
it { expect(html).to include 'btn-warning' }
|
105
|
+
end
|
106
|
+
|
107
|
+
describe 'set to :danger, shows a "danger" dropdown button' do
|
108
|
+
let(:context) { :danger }
|
109
|
+
it { expect(html).to include 'btn-danger' }
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'set to :link, shows a "link" dropdown button' do
|
113
|
+
let(:context) { :link }
|
114
|
+
it { expect(html).to include 'btn-link' }
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'set to any other value, shows a "default" dropdown button' do
|
118
|
+
let(:context) { :unknown }
|
119
|
+
it { expect(html).to include 'btn-default' }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'without the :context option, shows a "default" dropdown button' do
|
124
|
+
let(:options) { {} }
|
125
|
+
it { expect(html).to include 'btn-default' }
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'with the :size option' do
|
129
|
+
let(:options) { {size: size} }
|
130
|
+
|
131
|
+
describe 'set to :large, shows a large dropdown button' do
|
132
|
+
let(:size) { :large }
|
133
|
+
it { expect(html).to include 'btn-lg' }
|
134
|
+
end
|
135
|
+
|
136
|
+
describe 'set to :small, shows a small dropdown button' do
|
137
|
+
let(:size) { :small }
|
138
|
+
it { expect(html).to include 'btn-sm' }
|
139
|
+
end
|
140
|
+
|
141
|
+
describe 'set to :extra_small, shows an extra-small dropdown button' do
|
142
|
+
let(:size) { :extra_small }
|
143
|
+
it { expect(html).to include 'btn-xs' }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|