bh 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +5 -0
  5. data/app/views/bh/_table.html.erb +2 -4
  6. data/bh.gemspec +8 -7
  7. data/lib/bh/bootstrap_helpers.rb +10 -4
  8. data/lib/bh/version.rb +1 -1
  9. metadata +3 -45
  10. data/Rakefile +0 -11
  11. data/gemfiles/Gemfile.rails-3.x +0 -8
  12. data/gemfiles/Gemfile.rails-4.x +0 -8
  13. data/gemfiles/Gemfile.rails-5.x +0 -7
  14. data/spec/padrino/button_to_helper.rb +0 -35
  15. data/spec/padrino/link_to_helper.rb +0 -12
  16. data/spec/padrino_spec.rb +0 -29
  17. data/spec/rails/button_to_helper.rb +0 -31
  18. data/spec/rails/form/check_box_helper_spec.rb +0 -112
  19. data/spec/rails/form/field_helper_spec.rb +0 -138
  20. data/spec/rails/form/fields_for_helper_spec.rb +0 -65
  21. data/spec/rails/form/fieldset_helper_spec.rb +0 -32
  22. data/spec/rails/form/file_field_helper_spec.rb +0 -74
  23. data/spec/rails/form/legend_helper_spec.rb +0 -35
  24. data/spec/rails/form/radio_button_helper_spec.rb +0 -89
  25. data/spec/rails/form/select_helper_spec.rb +0 -88
  26. data/spec/rails/form/static_control_helper_spec.rb +0 -67
  27. data/spec/rails/form/submit_helper_spec.rb +0 -30
  28. data/spec/rails/form_for_helper_spec.rb +0 -50
  29. data/spec/rails/link_to_helper.rb +0 -12
  30. data/spec/rails_helper.rb +0 -24
  31. data/spec/rails_spec.rb +0 -29
  32. data/spec/shared/alert_box_helper.rb +0 -62
  33. data/spec/shared/button_helper.rb +0 -52
  34. data/spec/shared/button_to_helper.rb +0 -51
  35. data/spec/shared/cdn_helper.rb +0 -36
  36. data/spec/shared/dropdown_helper.rb +0 -112
  37. data/spec/shared/glyphicon_helper.rb +0 -21
  38. data/spec/shared/horizontal_helper.rb +0 -37
  39. data/spec/shared/icon_helper.rb +0 -31
  40. data/spec/shared/link_to_helper.rb +0 -84
  41. data/spec/shared/modal_helper.rb +0 -104
  42. data/spec/shared/nav_helper.rb +0 -49
  43. data/spec/shared/navbar_helper.rb +0 -63
  44. data/spec/shared/panel_helper.rb +0 -76
  45. data/spec/shared/panel_row_helper.rb +0 -21
  46. data/spec/shared/progress_bar_helper.rb +0 -103
  47. data/spec/shared/vertical_helper.rb +0 -43
  48. data/spec/spec_helper.rb +0 -22
  49. data/spec/support/matchers.rb +0 -47
  50. data/spec/support/padrino.rb +0 -33
  51. data/spec/support/rails.rb +0 -27
@@ -1,76 +0,0 @@
1
- shared_examples_for 'the panel helper' do
2
- all_tests_pass_with 'no panel options'
3
- all_tests_pass_with 'extra panel options (except :id)'
4
- all_tests_pass_with 'the :heading panel option'
5
- all_tests_pass_with 'the :title panel option'
6
- all_tests_pass_with 'the :body panel option'
7
- all_tests_pass_with 'the :context panel option'
8
- all_tests_pass_with 'the :tag panel option'
9
- all_tests_pass_with 'the panel wrapped in panel_row'
10
- end
11
-
12
- #--
13
-
14
- shared_examples_for 'no panel options' do
15
- specify 'displays a <div> with class="panel panel-default"' do
16
- html = %r{^<div class="panel panel-default">(?:|<div class="panel-body">)content(?:|</div>)</div>$}
17
- expect(:panel).to generate html
18
- end
19
- end
20
-
21
- shared_examples_for 'extra panel options (except :id)' do
22
- specify 'passes the options to the <div> panel' do
23
- options = {class: 'important', data: {value: 1}}
24
- html = %r{^<div class="important panel panel-default" data-value="1">(?:|<div class="panel-body">)content(?:|</div>)</div>$}
25
- expect(panel: options).to generate html
26
- end
27
- end
28
-
29
- shared_examples_for 'the :heading panel option' do
30
- specify 'sets the heading of the panel to the specified value' do
31
- html = %r{^<div class="panel panel-default"><div class="panel-heading">Heading</div>}
32
- expect(panel: {heading: 'Heading'}).to generate html
33
- end
34
- end
35
-
36
- shared_examples_for 'the :title panel option' do
37
- specify 'sets the title of the panel to the specified value' do
38
- html = %r{^<div class="panel panel-default"><div class="panel-heading"><h3 class="panel-title">Title</h3></div>}
39
- expect(panel: {title: 'Title'}).to generate html
40
- end
41
- end
42
-
43
- shared_examples_for 'the :body panel option' do
44
- let(:html) { %r{<div class="panel-body">Body</div>} }
45
-
46
- specify 'given either a content or a block, is ignored' do
47
- expect(panel: {body: 'Body'}).not_to generate html
48
- end
49
-
50
- specify 'given neither content nor a block, it is displayed as the content' do
51
- expect(bh.panel(body: 'Body')).to match html
52
- end
53
- end
54
-
55
- shared_examples_for 'the :tag panel option' do
56
- specify 'uses the HTML tag instead of <div> to wrap the panel' do
57
- html = %r{^<aside class="panel panel-default">.*</aside>$}m
58
- expect(panel: {tag: :aside}).to generate html
59
- end
60
- end
61
-
62
- shared_examples_for 'the :context panel option' do
63
- Bh::Panel.contexts.each do |context, context_class|
64
- specify %Q{set to :#{context}, adds the class "#{context_class}"} do
65
- html = %r{^<div class="panel #{context_class}">.*</div>$}m
66
- expect(panel: {context: context}).to generate html
67
- end
68
- end
69
- end
70
-
71
- shared_examples_for 'the panel wrapped in panel_row' do
72
- specify 'wraps the panel <div> in a grid <div> with the :column_class class of the panel row' do
73
- html = %r{^<div class="col-sm-4"><div class="panel panel-default">(?:|<div class="panel-body">)content(?:|</div>)</div></div>$}
74
- bh.panel_row(column_class: 'col-sm-4') { expect(:panel).to generate html }
75
- end
76
- end
@@ -1,21 +0,0 @@
1
- shared_examples_for 'the panel_row helper' do
2
- all_tests_pass_with 'no panel_row options'
3
- all_tests_pass_with 'extra panel_row options'
4
- end
5
-
6
- #--
7
-
8
- shared_examples_for 'no panel_row options' do
9
- specify 'displays an <div> with class="row"' do
10
- html = '<div class="row">content</div>'
11
- expect(:panel_row).to generate html
12
- end
13
- end
14
-
15
- shared_examples_for 'extra panel_row options' do
16
- specify 'passes the options to the <div>' do
17
- options = {class: 'important', data: {value: 1}, id: 'my-panel-row'}
18
- html = '<div class="important row" data-value="1" id="my-panel-row">content</div>'
19
- expect(panel_row: options).to generate html
20
- end
21
- end
@@ -1,103 +0,0 @@
1
- shared_examples_for 'the progress_bar helper' do
2
- all_tests_pass_with 'no progress_bar options'
3
- all_tests_pass_with 'extra progress_bar container options'
4
- all_tests_pass_with 'extra progress_bar bar options'
5
- all_tests_pass_with 'the :percentage progress_bar option'
6
- all_tests_pass_with 'the :label progress_bar option'
7
- all_tests_pass_with 'the :context progress_bar option'
8
- all_tests_pass_with 'the :striped progress_bar option'
9
- all_tests_pass_with 'the :animated progress_bar option'
10
- all_tests_pass_with 'an array of progress_bar options'
11
- end
12
-
13
- #--
14
-
15
- shared_examples_for 'no progress_bar options' do
16
- specify 'displays an empty progress <div>' do
17
- html = '<div class="progress"></div>'
18
- expect(:progress_bar).to generate html
19
- end
20
- end
21
-
22
- shared_examples_for 'extra progress_bar container options' do
23
- specify 'passes the options to the <div>' do
24
- options = {class: 'important', data: {value: 1}, id: 'my-progress-bars'}
25
- html = '<div class="important progress" data-value="1" id="my-progress-bars"></div>'
26
- expect(progress_bar: [nil, options]).to generate html
27
- end
28
- end
29
-
30
- shared_examples_for 'extra progress_bar bar options' do
31
- specify 'passes the options to the bar <div>' do
32
- bar = {class: 'important', data: {value: 1}, id: 'my-progress-bar'}
33
- html = %r{<div.*class="important progress-bar" data-value="1" id="my-progress-bar".*role="progressbar"}
34
- expect(progress_bar: bar).to generate html
35
- end
36
- end
37
-
38
- shared_examples_for 'the :percentage progress_bar option' do
39
- specify 'displays one progress bar for the given value' do
40
- html = '<div class="progress"><div aria-valuemax="100" aria-valuemin="0" aria-valuenow="30" class="progress-bar" role="progressbar" style="width: 30%"><span class="sr-only">30%</span></div></div>'
41
- expect(progress_bar: {percentage: 30}).to generate html
42
- end
43
- end
44
-
45
- shared_examples_for 'the :label progress_bar option' do
46
- specify 'set to false, hides the label' do
47
- html = %r{<div.+><span class="sr-only">30%<\/span>}
48
- expect(progress_bar: {percentage: 30, label: false}).to generate html
49
- end
50
-
51
- specify 'set to true, displays an auto-generated the label' do
52
- html = %r{<div.+>30%<\/div>}
53
- expect(progress_bar: {percentage: 30, label: true}).to generate html
54
- end
55
-
56
- specify 'set to a string, displays the string as the label' do
57
- html = %r{<div.+>Thirty<\/div>}
58
- expect(progress_bar: {percentage: 30, label: 'Thirty'}).to generate html
59
- end
60
- end
61
-
62
- shared_examples_for 'the :context progress_bar option' do
63
- Bh::ProgressBar.contexts.each do |context, context_class|
64
- specify %Q{set to :#{context}, adds the class "#{context_class}"} do
65
- html = %r{<div.+class="progress-bar #{context_class}"}
66
- expect(progress_bar: {percentage: 30, context: context}).to generate html
67
- end
68
- end
69
- end
70
-
71
- shared_examples_for 'the :striped progress_bar option' do
72
- specify 'set to false, displays a solid color bar' do
73
- html = %r{<div.+class="progress-bar"}
74
- expect(progress_bar: {percentage: 30, striped: false}).to generate html
75
- end
76
-
77
- specify 'set to true, displays a striped color bar' do
78
- html = %r{<div.+class="progress-bar progress-bar-striped"}
79
- expect(progress_bar: {percentage: 30, striped: true}).to generate html
80
- end
81
- end
82
-
83
- shared_examples_for 'the :animated progress_bar option' do
84
- specify 'set to false, displays a static bar' do
85
- html = %r{<div.+class="progress-bar"}
86
- expect(progress_bar: {percentage: 30, animated: false}).to generate html
87
- end
88
-
89
- specify 'set to true, displays an animated striped bar' do
90
- html = %r{<div.+class="progress-bar progress-bar-striped active"}
91
- expect(progress_bar: {percentage: 30, animated: true}).to generate html
92
- end
93
- end
94
-
95
- shared_examples_for 'an array of progress_bar options' do
96
- specify 'displays a group of stacked progress bars with their options' do
97
- bar_1 = '<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="30" class="progress-bar" role="progressbar" style="width: 30%"><span class="sr-only">30%</span></div>'
98
- bar_2 = '<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="40" class="progress-bar" role="progressbar" style="width: 40%"><span class="sr-only">40%</span></div>'
99
- html = %Q{<div class="progress">#{bar_1}\n#{bar_2}</div>}
100
- bars = [{percentage: 30}, {percentage: 40}]
101
- expect(progress_bar: [bars, {}]).to generate html
102
- end
103
- end
@@ -1,43 +0,0 @@
1
- shared_examples_for 'the vertical helper' do
2
- all_tests_pass_with 'the vertical not wrapped in navbar'
3
- all_tests_pass_with 'no vertical options'
4
- all_tests_pass_with 'extra vertical options'
5
- all_tests_pass_with 'the vertical wrapped in a navbar with :id'
6
- end
7
-
8
- #--
9
-
10
- shared_examples_for 'the vertical not wrapped in navbar' do
11
- specify 'returns nil' do
12
- expect(:vertical).to generate nil
13
- end
14
- end
15
-
16
- shared_examples_for 'no vertical options' do
17
- specify 'creates a <div> element with the "navbar-header" class and toggle button' do
18
- html = <<-EOT.strip_heredoc.strip
19
- <div class="navbar-header"><button class="navbar-toggle" data-target="#(.+)" data-toggle="collapse" type="button"><span class="sr-only">Toggle navigation</span>
20
- <span class="icon-bar"></span>
21
- <span class="icon-bar"></span>
22
- <span class="icon-bar"></span></button>
23
- content</div>
24
- EOT
25
- bh.navbar { expect(:vertical).to generate %r{#{html}} }
26
- end
27
- end
28
-
29
- shared_examples_for 'extra vertical options' do
30
- specify 'passes the options to the <div> element' do
31
- options = {class: 'important', data: {value: 1}, id: 'my-navbar-header'}
32
- html = %r{<div class="important navbar-header" data-value="1" id="my-navbar-header">}
33
- bh.navbar { expect(vertical: options).to generate html }
34
- end
35
- end
36
-
37
- shared_examples_for 'the vertical wrapped in a navbar with :id' do
38
- it 'uses the id from the navbar' do
39
- id = 'my-navbar'
40
- html = %r{button class="navbar-toggle" data-target="##{id}"}
41
- bh.navbar(id: id) { expect(:vertical).to generate html}
42
- end
43
- end
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
-
4
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
5
- SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
7
- ]
8
- SimpleCov.start
9
-
10
- require 'bh'
11
-
12
- Dir['./spec/shared/**/*.rb'].each {|f| require f}
13
- require './spec/support/matchers.rb'
14
- require './spec/support/padrino.rb' unless ENV['ONLY_RAILS']
15
- require './spec/support/rails.rb'
16
-
17
- RSpec.configure do |config|
18
- config.order = 'random'
19
- config.run_all_when_everything_filtered = false
20
- config.alias_it_should_behave_like_to :all_tests_pass_for, ''
21
- config.alias_it_should_behave_like_to :all_tests_pass_with, 'with'
22
- end
@@ -1,47 +0,0 @@
1
- RSpec::Matchers.define :generate do |html|
2
- match do |helper, options = nil|
3
- if helper.is_a?(Hash)
4
- helper, options = helper.keys.first, helper.values.first
5
- end
6
-
7
- if helper == :link_to && options == :nil_name
8
- @inline = bh.send helper, nil, '/'
9
- @block = @inline
10
- elsif helper == :link_to && options == :xss_script
11
- @inline = bh.send helper, '<script>alert("xss")</script>', '/'
12
- @block = bh.send(helper, '/') { '<script>alert("xss")</script>' }
13
- elsif helper == :link_to && options == :safe_html
14
- @inline = bh.send helper, bh.tag(:hr), '/'
15
- @block = bh.send(helper, '/') { bh.tag(:hr) }
16
- elsif helper == :link_to || helper == :button_to
17
- @inline = bh.send helper, *['content', '/', options].compact
18
- if bh.test_button_to_with_block
19
- @block = bh.send(helper, *['/', options].compact) { 'content' }
20
- else
21
- @block = @inline
22
- end
23
- elsif helper == :dropdown
24
- @block = bh.send(helper, *['caption', options].compact) { 'content' }
25
- @inline = @block
26
- elsif helper == :glyphicon || helper == :icon
27
- @inline = bh.send helper, *['zoom-in', options].compact
28
- @block = bh.send helper, *[:zoom_in, options].compact
29
- elsif helper == :progress_bar
30
- @inline = bh.send helper, *Array.wrap(options)
31
- @block = @inline
32
- elsif helper == :navbar || helper == :nav || helper == :panel_row
33
- @block = bh.send(helper, *[options].compact) { 'content' }
34
- @inline = @block
35
- else
36
- @inline = bh.send helper, *['content', options].compact
37
- @block = bh.send(helper, *[options].compact) { 'content' }
38
- end
39
-
40
- case html
41
- when Regexp then @inline.match(html) && @block.match(html)
42
- else @inline.eql?(html) && @block.eql?(html)
43
- end
44
- end
45
-
46
- failure_message{|actual| "expected #{html}, got #{@inline} and #{@block}"}
47
- end
@@ -1,33 +0,0 @@
1
- require 'tilt'
2
- require 'padrino-helpers'
3
- require 'padrino-routing'
4
-
5
- # A view that behaves like a Padrino view
6
- class PadrinoView
7
- include Padrino::Helpers::OutputHelpers # for capture
8
- include Padrino::Helpers::TagHelpers # for content_tag
9
- include Padrino::Helpers::AssetTagHelpers # for link_to
10
- include Padrino::Helpers::FormHelpers # for button_to
11
- include Padrino::Routing::Helpers # for url_for
12
- include Bh::Helpers
13
-
14
- def self.app_name
15
- 'test'
16
- end
17
-
18
- def self.named_paths
19
- {[:test, "/"] => '/'}
20
- end
21
-
22
- def self.uri_root
23
- '/'
24
- end
25
-
26
- def request
27
- Rack::Request.new 'REQUEST_METHOD' => 'GET'
28
- end
29
-
30
- def test_button_to_with_block
31
- false
32
- end
33
- end
@@ -1,27 +0,0 @@
1
- require 'action_dispatch'
2
- require 'action_view'
3
-
4
- # A view that behaves like a Rails/ActionView view
5
- class RailsView
6
- include ActionView::Context # for capture
7
- include ActionView::Helpers::RenderingHelper # for render
8
- include ActionView::Helpers::TagHelper # for content_tag
9
- include ActionView::Helpers::UrlHelper # for link_to
10
-
11
- include Bh::Helpers
12
-
13
- def initialize
14
- end
15
-
16
- def request
17
- ActionDispatch::Request.new 'REQUEST_METHOD' => 'GET'
18
- end
19
-
20
- def protect_against_forgery?
21
- false
22
- end
23
-
24
- def test_button_to_with_block
25
- true
26
- end
27
- end