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
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
Dir['./spec/padrino/*_helper.rb'].each {|f| require f}
|
3
|
+
|
4
|
+
describe 'When used in Padrino or Middleman' do
|
5
|
+
let(:bh) { PadrinoView.new }
|
6
|
+
before { Bh.framework = :padrino }
|
7
|
+
|
8
|
+
all_tests_pass_for 'the alert_box helper'
|
9
|
+
all_tests_pass_for 'the bootstrap_css helper'
|
10
|
+
all_tests_pass_for 'the bootstrap_js helper'
|
11
|
+
all_tests_pass_for 'the bootstrap_theme_css helper'
|
12
|
+
all_tests_pass_for 'the button helper'
|
13
|
+
all_tests_pass_for 'the dropdown helper'
|
14
|
+
all_tests_pass_for 'the font_awesome_css helper'
|
15
|
+
all_tests_pass_for 'the glyphicon helper'
|
16
|
+
all_tests_pass_for 'the horizontal helper'
|
17
|
+
all_tests_pass_for 'the icon helper'
|
18
|
+
all_tests_pass_for 'the modal helper'
|
19
|
+
all_tests_pass_for 'the nav helper'
|
20
|
+
all_tests_pass_for 'the navbar helper'
|
21
|
+
all_tests_pass_for 'the panel helper'
|
22
|
+
all_tests_pass_for 'the panel_row helper'
|
23
|
+
all_tests_pass_for 'the progress_bar helper'
|
24
|
+
all_tests_pass_for 'the vertical helper'
|
25
|
+
|
26
|
+
all_tests_pass_for 'the button_to helper (Padrino)'
|
27
|
+
all_tests_pass_for 'the link_to helper'
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
shared_examples_for 'the button_to helper (Rails)' do
|
2
|
+
all_tests_pass_with 'no button_to options (Rails)'
|
3
|
+
all_tests_pass_with 'only extra button_to options (Rails)'
|
4
|
+
all_tests_pass_with 'extra button_to options (Rails)'
|
5
|
+
all_tests_pass_for 'the button_to helper'
|
6
|
+
end
|
7
|
+
|
8
|
+
#--
|
9
|
+
|
10
|
+
shared_examples_for 'no button_to options (Rails)' do
|
11
|
+
specify 'uses the original button_to helper' do
|
12
|
+
html = %r{^<form action="/" class="button_to" method="post"><div><(input|button) type="submit"(>| value=")content(" />|</button>)</div></form>$}
|
13
|
+
expect(:button_to).to generate html
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
shared_examples_for 'only extra button_to options (Rails)' do
|
18
|
+
specify 'uses the original button_to helper' do
|
19
|
+
options = {class: 'important', data: {value: 1}, id: 'my-button_to'}
|
20
|
+
html = %r{<(input|button) class="important" data-value="1" id="my-button_to" type="submit"}
|
21
|
+
expect(button_to: options).to generate html
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
shared_examples_for 'extra button_to options (Rails)' do
|
26
|
+
specify 'passes the options to the button' do
|
27
|
+
options = {context: :default, class: 'important', data: {value: 1}, id: 'my-button_to'}
|
28
|
+
html = %r{<(input|button) class="important btn btn-default" data-value="1" id="my-button_to" type="submit"}
|
29
|
+
expect(button_to: options).to generate html
|
30
|
+
end
|
31
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'bh/
|
3
|
-
include Bh::
|
1
|
+
require 'rails_helper'
|
2
|
+
require 'bh/core_ext/rails/form_for_helper'
|
3
|
+
include Bh::Rails::Helpers
|
4
4
|
|
5
5
|
def self.field_helpers_to_test
|
6
6
|
types = %w(email number password phone search telephone text url)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'bh/
|
3
|
-
include Bh::
|
1
|
+
require 'rails_helper'
|
2
|
+
require 'bh/core_ext/rails/form_for_helper'
|
3
|
+
include Bh::Rails::Helpers
|
4
4
|
|
5
5
|
describe 'static_control' do
|
6
6
|
let(:protect_against_forgery?) { false }
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
class User
|
5
|
+
require 'active_model'
|
6
|
+
|
7
|
+
include ActiveModel::Validations
|
8
|
+
include ActiveModel::Conversion
|
9
|
+
extend ActiveModel::Naming
|
10
|
+
|
11
|
+
attr_accessor :name
|
12
|
+
|
13
|
+
def initialize(attributes = {})
|
14
|
+
@name = attributes[:name]
|
15
|
+
end
|
16
|
+
|
17
|
+
def persisted?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'action_view'
|
23
|
+
include ActionView::Helpers::FormOptionsHelper
|
24
|
+
include defined?(ActionView::VERSION) ? ActionView::RecordIdentifier : ActionController::RecordIdentifier
|
25
|
+
I18n.enforce_available_locales = true
|
data/spec/rails_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
Dir['./spec/rails/*_helper.rb'].each {|f| require f}
|
3
|
+
|
4
|
+
describe 'When used in Rails' do
|
5
|
+
let(:bh) { RailsView.new }
|
6
|
+
before { Bh.framework = :rails }
|
7
|
+
|
8
|
+
all_tests_pass_for 'the alert_box helper'
|
9
|
+
all_tests_pass_for 'the bootstrap_css helper'
|
10
|
+
all_tests_pass_for 'the bootstrap_js helper'
|
11
|
+
all_tests_pass_for 'the bootstrap_theme_css helper'
|
12
|
+
all_tests_pass_for 'the button helper'
|
13
|
+
all_tests_pass_for 'the dropdown helper'
|
14
|
+
all_tests_pass_for 'the font_awesome_css helper'
|
15
|
+
all_tests_pass_for 'the glyphicon helper'
|
16
|
+
all_tests_pass_for 'the horizontal helper'
|
17
|
+
all_tests_pass_for 'the icon helper'
|
18
|
+
all_tests_pass_for 'the modal helper'
|
19
|
+
all_tests_pass_for 'the nav helper'
|
20
|
+
all_tests_pass_for 'the navbar helper'
|
21
|
+
all_tests_pass_for 'the panel helper'
|
22
|
+
all_tests_pass_for 'the panel_row helper'
|
23
|
+
all_tests_pass_for 'the progress_bar helper'
|
24
|
+
all_tests_pass_for 'the vertical helper'
|
25
|
+
|
26
|
+
all_tests_pass_for 'the button_to helper (Rails)'
|
27
|
+
all_tests_pass_for 'the link_to helper'
|
28
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
shared_examples_for 'the alert_box helper' do
|
2
|
+
all_tests_pass_with 'no alert options'
|
3
|
+
all_tests_pass_with 'extra alert options'
|
4
|
+
all_tests_pass_with 'the :context alert option'
|
5
|
+
all_tests_pass_with 'the :dismissible alert option'
|
6
|
+
all_tests_pass_with 'the :priority alert option'
|
7
|
+
end
|
8
|
+
|
9
|
+
#--
|
10
|
+
|
11
|
+
shared_examples_for 'no alert options' do
|
12
|
+
specify 'sets the role and the class to "alert"' do
|
13
|
+
html = '<div class="alert alert-info" role="alert">content</div>'
|
14
|
+
expect(:alert_box).to generate html
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
shared_examples_for 'extra alert options' do
|
19
|
+
specify 'passes the options to the wrapping <div>' do
|
20
|
+
options = {class: 'important', data: {value: 1}, id: 'my-alert'}
|
21
|
+
html = '<div class="important alert alert-info" data-value="1" id="my-alert" role="alert">content</div>'
|
22
|
+
expect(alert_box: options).to generate html
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
shared_examples_for 'the :context alert option' do
|
27
|
+
Bh::AlertBox.contexts.each do |context, context_class|
|
28
|
+
specify %Q{set to :#{context}, adds the class "#{context_class}"} do
|
29
|
+
html = %Q{<div class="alert #{context_class}" role="alert">content</div>}
|
30
|
+
expect(alert_box: {context: context.to_s}).to generate html
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
shared_examples_for 'the :dismissible alert option' do
|
36
|
+
specify 'set to false, does not display a button to dismiss the alert' do
|
37
|
+
html = '<div class="alert alert-info" role="alert">content</div>'
|
38
|
+
expect(alert_box: {dismissible: false}).to generate html
|
39
|
+
end
|
40
|
+
|
41
|
+
specify 'set to true, displays a button to dismiss the alert' do
|
42
|
+
html = %r{<span aria-hidden="true">×</span>}
|
43
|
+
expect(alert_box: {dismissible: true}).to generate html
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
shared_examples_for 'the :priority alert option' do
|
48
|
+
specify 'set, displays a button to dismiss the alert' do
|
49
|
+
html = %r{<span aria-hidden="true">×</span>}
|
50
|
+
expect(alert_box: {priority: :anything}).to generate html
|
51
|
+
end
|
52
|
+
|
53
|
+
specify 'set to :notice, adds the class "alert-success"' do
|
54
|
+
html = %r{<div class="alert alert-success" role="alert">}
|
55
|
+
expect(alert_box: {priority: :notice}).to generate html
|
56
|
+
end
|
57
|
+
|
58
|
+
specify 'set to :alert, adds the class "alert-danger"' do
|
59
|
+
html = %r{<div class="alert alert-danger" role="alert">}
|
60
|
+
expect(alert_box: {priority: :alert}).to generate html
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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
|
@@ -0,0 +1,42 @@
|
|
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
|
+
end
|
7
|
+
|
8
|
+
#--
|
9
|
+
|
10
|
+
shared_examples_for 'the :context button_to option' do
|
11
|
+
Bh::Button.contexts.each do |context, context_class|
|
12
|
+
specify %Q{set to :#{context}, adds the class "#{context_class}"} do
|
13
|
+
html = %r{<(input|button).+class="btn #{context_class}"}
|
14
|
+
expect(button_to: {context: context}).to generate html
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
shared_examples_for 'the :size button_to option' do
|
20
|
+
Bh::Button.sizes.each do |size, size_class|
|
21
|
+
specify %Q{set to :#{size}, adds the class "#{size_class}"} do
|
22
|
+
html = %r{<(input|button).+class="btn btn-default #{size_class}"}
|
23
|
+
expect(button_to: {size: size}).to generate html
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
shared_examples_for 'the :layout button_to option' do
|
29
|
+
Bh::Button.layouts.each do |layout, layout_class|
|
30
|
+
specify %Q{set to :#{layout}, adds the class "#{layout_class}"} do
|
31
|
+
html = %r{<(input|button).+class="btn btn-default #{layout_class}"}
|
32
|
+
expect(button_to: {layout: layout}).to generate html
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
shared_examples_for 'the button wrapped in navbar' do
|
38
|
+
specify 'adds the "navbar-form" class to the form' do
|
39
|
+
html = %r{^<form.+class="navbar-form"}
|
40
|
+
bh.navbar { expect(button_to: {context: :default}).to generate html }
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
@@ -0,0 +1,112 @@
|
|
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
|