bh 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/CHANGELOG.md +19 -0
- data/README.md +51 -18
- data/bh.gemspec +13 -9
- data/examples/middleman/.gitignore +18 -0
- data/examples/middleman/Gemfile +6 -0
- data/examples/middleman/config.rb +1 -0
- data/examples/middleman/source/index.html.erb +158 -0
- data/examples/padrino/Gemfile +9 -0
- data/examples/padrino/app/app.rb +16 -0
- data/examples/padrino/app/views/index.html.erb +155 -0
- data/examples/padrino/config.ru +5 -0
- data/examples/padrino/config/apps.rb +5 -0
- data/examples/padrino/config/boot.rb +8 -0
- data/examples/rails/.gitignore +12 -0
- data/examples/rails/Gemfile +5 -0
- data/examples/rails/app/controllers/application_controller.rb +6 -0
- data/examples/rails/app/controllers/users_controller.rb +2 -0
- data/examples/rails/app/models/user.rb +15 -0
- data/examples/rails/app/views/application/index.html.erb +160 -0
- data/examples/rails/bin/rails +4 -0
- data/examples/rails/config.ru +4 -0
- data/examples/rails/config/application.rb +12 -0
- data/examples/rails/config/boot.rb +3 -0
- data/examples/rails/config/environment.rb +5 -0
- data/examples/rails/config/environments/development.rb +7 -0
- data/examples/rails/config/routes.rb +4 -0
- data/examples/rails/config/secrets.yml +22 -0
- data/examples/rails/log/.keep +0 -0
- data/gemfiles/Gemfile.rails-3.x +2 -0
- data/gemfiles/Gemfile.rails-4.x +2 -0
- data/lib/bh.rb +15 -4
- data/lib/bh/classes/alert_box.rb +35 -0
- data/lib/bh/classes/base.rb +125 -0
- data/lib/bh/classes/button.rb +58 -0
- data/lib/bh/classes/button_to.rb +33 -0
- data/lib/bh/classes/cdn.rb +35 -0
- data/lib/bh/classes/dropdown.rb +56 -0
- data/lib/bh/classes/icon.rb +34 -0
- data/lib/bh/classes/link_to.rb +22 -0
- data/lib/bh/classes/modal.rb +68 -0
- data/lib/bh/classes/nav.rb +37 -0
- data/lib/bh/classes/navbar.rb +78 -0
- data/lib/bh/classes/panel.rb +72 -0
- data/lib/bh/classes/panel_row.rb +13 -0
- data/lib/bh/classes/progress_bar.rb +89 -0
- data/lib/bh/classes/stack.rb +19 -0
- data/lib/bh/classes/vertical.rb +27 -0
- data/lib/bh/core_ext/middleman.rb +24 -0
- data/lib/bh/core_ext/padrino.rb +25 -0
- data/lib/bh/core_ext/rails/base_helper.rb +21 -0
- data/lib/bh/{helpers → core_ext/rails}/form/base_helper.rb +3 -1
- data/lib/bh/{helpers → core_ext/rails}/form/check_box_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/field_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/fields_for_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/fieldset_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/file_field_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/legend_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/radio_button_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/select_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/static_control_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/submit_helper.rb +1 -1
- data/lib/bh/{form_builders → core_ext/rails}/form_builder.rb +11 -10
- data/lib/bh/core_ext/rails/form_for_helper.rb +32 -0
- data/lib/bh/core_ext/railtie.rb +27 -0
- data/lib/bh/helpers/alert_box_helper.rb +40 -0
- data/lib/bh/helpers/button_helper.rb +35 -58
- data/lib/bh/helpers/button_to_helper.rb +48 -10
- data/lib/bh/helpers/cdn_helper.rb +11 -35
- data/lib/bh/helpers/dropdown_helper.rb +29 -62
- data/lib/bh/helpers/glyphicon_helper.rb +7 -13
- data/lib/bh/helpers/horizontal_helper.rb +35 -0
- data/lib/bh/helpers/icon_helper.rb +15 -29
- data/lib/bh/helpers/link_to_helper.rb +52 -41
- data/lib/bh/helpers/modal_helper.rb +49 -79
- data/lib/bh/helpers/nav_helper.rb +25 -40
- data/lib/bh/helpers/navbar_helper.rb +36 -170
- data/lib/bh/helpers/panel_helper.rb +45 -72
- data/lib/bh/helpers/panel_row_helper.rb +20 -38
- data/lib/bh/helpers/progress_bar_helper.rb +48 -59
- data/lib/bh/helpers/vertical_helper.rb +33 -0
- data/lib/bh/version.rb +1 -1
- data/lib/bh/views/bh/_alert_dismiss_button.html +4 -0
- data/lib/bh/views/bh/_dropdown.html.erb +5 -5
- data/lib/bh/views/bh/_dropdown_split.html.erb +5 -5
- data/lib/bh/views/bh/_modal.html.erb +5 -8
- data/lib/bh/views/bh/_navbar.html.erb +5 -0
- data/spec/padrino/button_to_helper.rb +35 -0
- data/spec/padrino_spec.rb +28 -0
- data/spec/rails/button_to_helper.rb +31 -0
- data/spec/{helpers → rails}/form/check_box_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/field_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/fields_for_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/fieldset_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/file_field_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/legend_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/radio_button_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/select_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/static_control_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/submit_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form_for_helper_spec.rb +3 -3
- data/spec/rails_helper.rb +25 -0
- data/spec/rails_spec.rb +28 -0
- data/spec/shared/alert_box_helper.rb +62 -0
- data/spec/shared/button_helper.rb +52 -0
- data/spec/shared/button_to_helper.rb +42 -0
- data/spec/shared/cdn_helper.rb +36 -0
- data/spec/shared/dropdown_helper.rb +112 -0
- data/spec/shared/glyphicon_helper.rb +21 -0
- data/spec/shared/horizontal_helper.rb +37 -0
- data/spec/shared/icon_helper.rb +31 -0
- data/spec/shared/link_to_helper.rb +62 -0
- data/spec/shared/modal_helper.rb +104 -0
- data/spec/shared/nav_helper.rb +49 -0
- data/spec/shared/navbar_helper.rb +63 -0
- data/spec/shared/panel_helper.rb +76 -0
- data/spec/shared/panel_row_helper.rb +21 -0
- data/spec/shared/progress_bar_helper.rb +103 -0
- data/spec/shared/vertical_helper.rb +43 -0
- data/spec/spec_helper.rb +6 -29
- data/spec/support/matchers.rb +38 -0
- data/spec/support/padrino.rb +33 -0
- data/spec/support/rails.rb +27 -0
- metadata +183 -94
- data/config.rb +0 -6
- data/lib/bh/helpers/alert_helper.rb +0 -77
- data/lib/bh/helpers/base_helper.rb +0 -39
- data/lib/bh/helpers/form_for_helper.rb +0 -30
- data/lib/bh/middleman.rb +0 -39
- data/lib/bh/railtie.rb +0 -42
- data/spec/dummy/index.html.erb +0 -60
- data/spec/dummy/layouts/default.erb +0 -17
- data/spec/helpers/alert_helper_spec.rb +0 -84
- data/spec/helpers/button_helper_spec.rb +0 -100
- data/spec/helpers/button_to_helper_spec.rb +0 -25
- data/spec/helpers/cdn_helper_spec.rb +0 -100
- data/spec/helpers/dropdown_helper_spec.rb +0 -146
- data/spec/helpers/glyphicon_helper_spec.rb +0 -21
- data/spec/helpers/icon_helper_spec.rb +0 -45
- data/spec/helpers/link_to_helper_spec.rb +0 -124
- data/spec/helpers/modal_helper_spec.rb +0 -133
- data/spec/helpers/nav_helper_spec.rb +0 -53
- data/spec/helpers/navbar_helper_spec.rb +0 -194
- data/spec/helpers/panel_helper_spec.rb +0 -95
- data/spec/helpers/panel_row_helper_spec.rb +0 -27
- data/spec/helpers/progress_bar_helper_spec.rb +0 -114
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'bh/helpers/button_to_helper'
|
4
|
-
require 'bh/helpers/navbar_helper'
|
5
|
-
|
6
|
-
include Bh::ButtonToHelper
|
7
|
-
include Bh::NavbarHelper
|
8
|
-
|
9
|
-
describe 'button_to' do
|
10
|
-
let(:protect_against_forgery?) { false }
|
11
|
-
attr_accessor :output_buffer
|
12
|
-
let(:url) { '/' }
|
13
|
-
|
14
|
-
context 'used without a block' do
|
15
|
-
let(:button) { button_to 'Home', url }
|
16
|
-
|
17
|
-
specify 'by default, applies the "btn" class' do
|
18
|
-
expect(button).to include 'input class="btn" type="submit" value="Home"'
|
19
|
-
end
|
20
|
-
|
21
|
-
specify 'inside a navbar, also applies the "navbar-form" class to the form' do
|
22
|
-
expect(navbar { button }).to match %r{<form .+?class="navbar-form" .+?input class="btn"}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'bh/helpers/cdn_helper'
|
3
|
-
require 'open-uri'
|
4
|
-
include Bh::CdnHelper
|
5
|
-
|
6
|
-
describe 'bootstrap_css' do
|
7
|
-
let(:file) { open bootstrap_css(options), ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
8
|
-
|
9
|
-
describe 'with the HTTP scheme, links to an existing file' do
|
10
|
-
let(:options) { {scheme: :http} }
|
11
|
-
it{ expect(file).to be }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'with the HTTPS scheme, links to an existing file' do
|
15
|
-
let(:options) { {scheme: :https} }
|
16
|
-
it{ expect(file).to be }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'non-minified, links to an existing file' do
|
20
|
-
let(:options) { {scheme: :http, minified: false} }
|
21
|
-
it{ expect(file).to be }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'given a legacy version, links to an existing file' do
|
25
|
-
let(:options) { {scheme: :https, version: '3.1.0'} }
|
26
|
-
it{ expect(file).to be }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe 'bootstrap_theme_css' do
|
31
|
-
let(:file) { open bootstrap_theme_css(options), ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
32
|
-
|
33
|
-
describe 'with the HTTP scheme, links to an existing file' do
|
34
|
-
let(:options) { {scheme: :http} }
|
35
|
-
it{ expect(file).to be }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'with the HTTPS scheme, links to an existing file' do
|
39
|
-
let(:options) { {scheme: :https} }
|
40
|
-
it{ expect(file).to be }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'non-minified, links to an existing file' do
|
44
|
-
let(:options) { {scheme: :http, minified: false} }
|
45
|
-
it{ expect(file).to be }
|
46
|
-
end
|
47
|
-
|
48
|
-
describe 'given a legacy version, links to an existing file' do
|
49
|
-
let(:options) { {scheme: :https, version: '3.1.0'} }
|
50
|
-
it{ expect(file).to be }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe 'bootstrap_js' do
|
55
|
-
let(:file) { open bootstrap_js(options), ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
56
|
-
|
57
|
-
describe 'with the HTTP scheme, links to an existing file' do
|
58
|
-
let(:options) { {scheme: :http} }
|
59
|
-
it{ expect(file).to be }
|
60
|
-
end
|
61
|
-
|
62
|
-
describe 'with the HTTPS scheme, links to an existing file' do
|
63
|
-
let(:options) { {scheme: :https} }
|
64
|
-
it{ expect(file).to be }
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'non-minified, links to an existing file' do
|
68
|
-
let(:options) { {scheme: :http, minified: false} }
|
69
|
-
it{ expect(file).to be }
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'given a legacy version, links to an existing file' do
|
73
|
-
let(:options) { {scheme: :https, version: '3.1.0'} }
|
74
|
-
it{ expect(file).to be }
|
75
|
-
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
|
@@ -1,146 +0,0 @@
|
|
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
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'bh/helpers/glyphicon_helper'
|
3
|
-
include Bh::GlyphiconHelper
|
4
|
-
|
5
|
-
describe 'glyphicon' do
|
6
|
-
specify 'given an icon name with underscores, returns the icon' do
|
7
|
-
expect(glyphicon :zoom_in).to eq '<span class="glyphicon glyphicon-zoom-in"></span>'
|
8
|
-
end
|
9
|
-
|
10
|
-
specify 'given an icon name with dashes, returns the icon' do
|
11
|
-
expect(glyphicon 'zoom-out').to eq '<span class="glyphicon glyphicon-zoom-out"></span>'
|
12
|
-
end
|
13
|
-
|
14
|
-
specify 'given no icon name, returns an empty icon' do
|
15
|
-
expect(glyphicon).to eq '<span class="glyphicon"></span>'
|
16
|
-
end
|
17
|
-
|
18
|
-
specify 'given extra options, passes the options to the <span>' do
|
19
|
-
expect(glyphicon :ok, title: 'Approved').to eq '<span class="glyphicon glyphicon-ok" title="Approved"></span>'
|
20
|
-
end
|
21
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'bh/helpers/icon_helper'
|
3
|
-
include Bh::IconHelper
|
4
|
-
|
5
|
-
describe 'icon' do
|
6
|
-
context 'given the icon name' do
|
7
|
-
specify 'has underscores, returns the icon with dashes' do
|
8
|
-
expect(icon :zoom_in).to eq '<span class="glyphicon glyphicon-zoom-in"></span>'
|
9
|
-
end
|
10
|
-
|
11
|
-
specify 'has dashes, returns the icon with dashes' do
|
12
|
-
expect(icon 'zoom-out').to eq '<span class="glyphicon glyphicon-zoom-out"></span>'
|
13
|
-
end
|
14
|
-
|
15
|
-
specify 'is missing, returns an empty icon' do
|
16
|
-
expect(icon).to eq '<span class="glyphicon"></span>'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'given the :library option (underscored)' do
|
21
|
-
specify 'is glyphicon, shows a Glyphicons icon' do
|
22
|
-
expect(icon :heart, library: :glyphicon).to eq '<span class="glyphicon glyphicon-heart"></span>'
|
23
|
-
end
|
24
|
-
|
25
|
-
specify 'is font-awesome, shows a Font Awesome icon' do
|
26
|
-
expect(icon :heart, library: 'font-awesome').to eq '<span class="fa fa-heart"></span>'
|
27
|
-
end
|
28
|
-
|
29
|
-
specify 'is font_awesome, shows a Font Awesome icon' do
|
30
|
-
expect(icon :heart, library: :font_awesome).to eq '<span class="fa fa-heart"></span>'
|
31
|
-
end
|
32
|
-
|
33
|
-
specify 'is any other string, uses the string as a prefix' do
|
34
|
-
expect(icon :heart, library: :custom).to eq '<span class="custom custom-heart"></span>'
|
35
|
-
end
|
36
|
-
|
37
|
-
specify 'is missing, shows a Glyphicons icon' do
|
38
|
-
expect(icon :heart).to eq '<span class="glyphicon glyphicon-heart"></span>'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
specify 'given extra options, passes the options to the <span>' do
|
43
|
-
expect(icon :ok, title: 'Approved').to eq '<span class="glyphicon glyphicon-ok" title="Approved"></span>'
|
44
|
-
end
|
45
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'action_dispatch'
|
3
|
-
|
4
|
-
require 'bh/helpers/alert_helper'
|
5
|
-
require 'bh/helpers/dropdown_helper'
|
6
|
-
require 'bh/helpers/link_to_helper'
|
7
|
-
require 'bh/helpers/nav_helper'
|
8
|
-
require 'bh/helpers/navbar_helper'
|
9
|
-
|
10
|
-
include Bh::AlertHelper
|
11
|
-
include Bh::DropdownHelper
|
12
|
-
include Bh::LinkToHelper
|
13
|
-
include Bh::NavHelper
|
14
|
-
include Bh::NavbarHelper
|
15
|
-
|
16
|
-
describe 'link_to' do
|
17
|
-
let(:request) { ActionDispatch::Request.new request_options }
|
18
|
-
let(:request_options) { {'REQUEST_METHOD' => 'GET'} }
|
19
|
-
let(:url) { '/' }
|
20
|
-
|
21
|
-
context 'used without a block' do
|
22
|
-
let(:link) { link_to 'Home', url }
|
23
|
-
|
24
|
-
specify 'by default, does not apply the "alert-link" class' do
|
25
|
-
expect(link).not_to include 'alert-link'
|
26
|
-
end
|
27
|
-
|
28
|
-
specify 'inside an alert, applies the "alert-link"' do
|
29
|
-
expect(alert_box { link }).to include 'alert-link'
|
30
|
-
end
|
31
|
-
|
32
|
-
specify 'by default, does not apply the "navbar-brand" class' do
|
33
|
-
expect(link).not_to include 'navbar-brand'
|
34
|
-
end
|
35
|
-
|
36
|
-
specify 'inside the vertical part of a navbar, applies the "navbar-brand"' do
|
37
|
-
expect(navbar { vertical { link } }).to include 'navbar-brand'
|
38
|
-
end
|
39
|
-
|
40
|
-
specify 'by default, does not surround the link in a list item' do
|
41
|
-
expect(link).not_to include '<li>'
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'inside a nav' do
|
45
|
-
let(:html) { nav { link } }
|
46
|
-
|
47
|
-
specify 'surrounds the link in a list item' do
|
48
|
-
expect(html).to include '<li><a href="/">Home</a></li>'
|
49
|
-
end
|
50
|
-
|
51
|
-
specify 'by default, does not apply the "active" class' do
|
52
|
-
expect(link).not_to include 'active'
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'given the link points to the current page, applies the "active" class' do
|
56
|
-
let(:url) { '' }
|
57
|
-
it { expect(html).to include 'li class="active"' }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'inside a dropdown' do
|
62
|
-
let(:views_folder) { File.expand_path('../../../lib/bh/views', __FILE__) }
|
63
|
-
let(:lookup_context) { ActionView::LookupContext.new views_folder }
|
64
|
-
let(:view_renderer) { ActionView::Renderer.new lookup_context }
|
65
|
-
let(:html) { dropdown('Menu') { link } }
|
66
|
-
|
67
|
-
specify 'surrounds the link in a list item, and adds role, tabindex' do
|
68
|
-
expect(html).to include '<li role="presentation"><a href="/" role="menuitem" tabindex="-1">Home</a></li>'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'used with a block' do
|
74
|
-
let(:link) { link_to(url) { 'Home' } }
|
75
|
-
|
76
|
-
specify 'by default, does not apply the "alert-link" class' do
|
77
|
-
expect(link).not_to include 'alert-link'
|
78
|
-
end
|
79
|
-
|
80
|
-
specify 'inside an alert, applies the "alert-link"' do
|
81
|
-
expect(alert_box { link }).to include 'alert-link'
|
82
|
-
end
|
83
|
-
|
84
|
-
specify 'by default, does not apply the "navbar-brand" class' do
|
85
|
-
expect(link).not_to include 'navbar-brand'
|
86
|
-
end
|
87
|
-
|
88
|
-
specify 'inside the vertical part of a navbar, applies the "navbar-brand"' do
|
89
|
-
expect(navbar { vertical { link } }).to include 'navbar-brand'
|
90
|
-
end
|
91
|
-
|
92
|
-
specify 'by default, does not surround the link in a list item' do
|
93
|
-
expect(link).not_to include '<li>'
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'inside a nav' do
|
97
|
-
let(:html) { nav { link } }
|
98
|
-
|
99
|
-
specify 'surrounds the link in a list item' do
|
100
|
-
expect(html).to include '<li><a href="/">Home</a></li>'
|
101
|
-
end
|
102
|
-
|
103
|
-
specify 'by default, does not apply the "active" class' do
|
104
|
-
expect(link).not_to include 'active'
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'given the link points to the current page, applies the "active" class' do
|
108
|
-
let(:url) { '' }
|
109
|
-
it { expect(html).to include 'li class="active"' }
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context 'inside a dropdown' do
|
114
|
-
let(:views_folder) { File.expand_path('../../../lib/bh/views', __FILE__) }
|
115
|
-
let(:lookup_context) { ActionView::LookupContext.new views_folder }
|
116
|
-
let(:view_renderer) { ActionView::Renderer.new lookup_context }
|
117
|
-
let(:html) { dropdown('Menu') { link } }
|
118
|
-
|
119
|
-
specify 'surrounds the link in a list item, and adds role, tabindex' do
|
120
|
-
expect(html).to include '<li role="presentation"><a href="/" role="menuitem" tabindex="-1">Home</a></li>'
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|