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,65 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'fields_for' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for user, layout: layout, url: '/', &block }
8
- let(:user) { User.new }
9
- let(:layout) { :whatever }
10
- let(:block) { Proc.new {|f| f.fields_for :address, options, &fields_block } }
11
- let(:options) { {} }
12
- let(:title) { nil }
13
- let(:fields_block) { Proc.new {|f| f.text_field :street } }
14
-
15
- describe 'with the :fieldset option' do
16
- specify 'not set, wraps the fields in a <fieldset> styled like a panel' do
17
- expect(form).to include 'fieldset class="panel panel-default">'
18
- end
19
-
20
- describe 'set to true, wraps the fields in a <fieldset> styled like a panel' do
21
- let(:options) { {fieldset: true} }
22
- it { expect(form).to include 'fieldset class="panel panel-default">' }
23
- end
24
-
25
- describe 'set to false, does not wrap the fields in a <fieldset>' do
26
- let(:options) { {fieldset: false} }
27
- it { expect(form).not_to include 'fieldset' }
28
- end
29
- end
30
-
31
- describe 'with the :title option' do
32
- specify 'not set, generates a title from the field name' do
33
- expect(form).to include '<div class="panel-heading">Address</div>'
34
- end
35
-
36
- context 'set to a value, uses the value as the panel title' do
37
- let(:options) { {title: 'Your address'} }
38
- it { expect(form).to include '<div class="panel-heading">Your address</div>' }
39
- end
40
- end
41
-
42
- describe 'with the :layout option' do
43
- specify 'not set, inherits the layout options of the parent form' do
44
- expect(form).to match %r{<div class="form-group"><label for.+?>Street</label>}
45
- end
46
-
47
- context 'set to a value, uses the value as the layout' do
48
- let(:options) { {layout: :horizontal} }
49
- it { expect(form).to match %r{<div class="form-group"><label class="col-sm-3 control-label" for.+?>Street</label>} }
50
- end
51
- end
52
-
53
- context 'given a record object' do
54
- let(:block) { Proc.new {|f| f.fields_for :address, user.name, options, &fields_block } }
55
-
56
- specify 'and no other options, uses the provided record object' do
57
- expect(form).to include 'fieldset class="panel panel-default">'
58
- end
59
-
60
- context 'and other options, uses the provided record object and options' do
61
- let(:options) { {title: 'Your address'} }
62
- it { expect(form).to include '<div class="panel-heading">Your address</div>' }
63
- end
64
- end
65
- end
@@ -1,32 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'fieldset' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for User.new, layout: layout, url: '/', &block }
8
- let(:block) { Proc.new {|f| f.fieldset title, &fieldset_block } }
9
- let(:title) { nil }
10
- let(:fieldset_block) { Proc.new { 'fieldset content' } }
11
- let(:layout) { :whatever }
12
-
13
- specify 'adds a <fieldset> that looks like a Bootstrap panel' do
14
- expect(form).to include 'fieldset class="panel panel-default">'
15
- end
16
-
17
- context 'given a title, and a non-inline layout, adds the title in the panel heading' do
18
- let(:title) { 'Info' }
19
- it { expect(form).to include '<div class="panel-heading">Info</div>' }
20
- end
21
-
22
- context 'given a title, and an inline layout, does not add a panel heading' do
23
- let(:layout) { :inline }
24
- let(:title) { 'Info' }
25
- it { expect(form).not_to include '<div class="panel-heading">Info</div>' }
26
- end
27
-
28
- context 'not given a title, does not add a panel heading' do
29
- let(:title) { '' }
30
- it { expect(form).not_to include 'panel-heading' }
31
- end
32
- end
@@ -1,74 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'file_field' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for user, layout: layout, errors: errors, url: '/', &block }
8
- let(:user) { User.new }
9
- let(:errors) { {} }
10
- let(:block) { Proc.new {|f| f.file_field :name, options.merge(accept: 'text/html')} }
11
- let(:options) { {} }
12
-
13
- context 'given any layout' do
14
- let(:layout) { :whatever }
15
-
16
- context 'not given a help option, does not display a help box' do
17
- it { expect(form).not_to include 'help-block' }
18
- end
19
-
20
- context 'given a help option, displays a help box' do
21
- let(:options) { {help: 'Please upload a file'} }
22
- it { expect(form).to include '<span class="help-block text-left">Please upload a file</span>' }
23
- end
24
- end
25
-
26
- describe 'given a basic layout' do
27
- let(:layout) { :basic }
28
- specify 'applies form-group to the container to the input' do
29
- expect(form).to match %r{<div class="form-group"><label.+?>Name</label><(input|textarea)}
30
- end
31
-
32
- specify 'does not apply form-control to the input' do
33
- expect(form).not_to match 'form-control'
34
- end
35
- end
36
-
37
- describe 'given a horizontal layout' do
38
- let(:layout) { :horizontal }
39
- specify 'applies form-group to the container, col-sm-3.control-label to the label and col-sm-9 to the field container' do
40
- expect(form).to match %r{<div class="form-group"><label class="col-sm-3 control-label".+?>Name</label><div class="col-sm-9"><(input|textarea)}
41
- end
42
-
43
- specify 'does not apply form-control to the input' do
44
- expect(form).not_to match 'form-control'
45
- end
46
- end
47
-
48
- describe 'given an inline layout' do
49
- let(:layout) { :inline }
50
- specify 'applies form-group to the container, sr-only to the label' do
51
- expect(form).to match %r{<div class="form-group"><label class="sr-only".+?>Name</label><(input|textarea)}
52
- end
53
-
54
- specify 'does not apply form-control to the input' do
55
- expect(form).not_to match 'form-control'
56
- end
57
-
58
- context 'given a help message' do
59
- let(:options) { {help: 'Please select a file'} }
60
-
61
- specify 'applies sr-only to the help message' do
62
- expect(form).to include '<span class="help-block text-left sr-only">Please select a file</span>'
63
- end
64
- end
65
-
66
- context 'given an error' do
67
- before { user.errors.add :name, 'cannot be nil' }
68
-
69
- specify 'applies sr-only to the error message' do
70
- expect(form).to include '<span class="help-block text-left sr-only">cannot be nil</span>'
71
- end
72
- end
73
- end
74
- end
@@ -1,35 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'legend' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for User.new, layout: layout, url: '/', &block }
8
- let(:block) { Proc.new {|f| f.legend 'Basic info' } }
9
- let(:layout) { :whatever }
10
-
11
- specify 'adds a <legend> to the form' do
12
- expect(form).to include 'legend'
13
- end
14
-
15
- describe 'given a basic layout' do
16
- let(:layout) { :basic }
17
- specify 'applies form-group to the container' do
18
- expect(form).to match %r{<div class="form-group"><legend>Basic info</legend></div>}
19
- end
20
- end
21
-
22
- describe 'given a horizontal layout' do
23
- let(:layout) { :horizontal }
24
- specify 'applies form-group to the container, col-sm-12 to the field container' do
25
- expect(form).to match %r{<div class="form-group"><div class="col-sm-12"><legend>Basic info</legend></div>}
26
- end
27
- end
28
-
29
- describe 'given an inline layout' do
30
- let(:layout) { :inline }
31
- specify 'applies sr-only to the legend' do
32
- expect(form).to match %r{<legend class="sr-only">Basic info</legend>}
33
- end
34
- end
35
- end
@@ -1,89 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'radio_button' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for user, layout: layout, errors: errors, url: '/', &block }
8
- let(:user) { User.new }
9
- let(:errors) { {} }
10
- let(:block) { Proc.new {|f| f.radio_button :name, 'Jeremy', options} }
11
- let(:options) { {} }
12
-
13
- context 'given any layout' do
14
- let(:layout) { :whatever }
15
-
16
- specify 'not given a label option, generates one from the value' do
17
- expect(form).to include '> Jeremy</label>'
18
- end
19
-
20
- context 'given a label option, uses the provided one' do
21
- let(:options) { {label: 'Jerry'} }
22
- it { expect(form).to include '> Jerry</label>' }
23
- end
24
-
25
- context 'given a label_options option, passes the options to the label' do
26
- let(:options) { {label_options: {class: 'col-sm-6', data: {js: 2}}} }
27
- it { expect(form).to match %r{<label class="col-sm-6" data-js="2"><input.+? /> Jeremy</label>} }
28
- end
29
-
30
- context 'not given a help option, does not display a help box' do
31
- it { expect(form).not_to include 'help-block' }
32
- end
33
-
34
- context 'given a help option, displays a help box' do
35
- let(:options) { {help: 'Please select an option'} }
36
- it { expect(form).to include '<span class="help-block text-left">Please select an option</span>' }
37
- end
38
-
39
- specify 'not given an error, does not apply has-error to the form group' do
40
- expect(form).not_to include 'has-error'
41
- end
42
-
43
- context 'given an error' do
44
- before { user.errors.add :name, 'cannot be nil' }
45
-
46
- specify 'shows errors and error messages' do
47
- expect(form).to include 'has-error'
48
- expect(form).to include '<span class="help-block text-left">cannot be nil</span>'
49
- end
50
- end
51
- end
52
-
53
- describe 'given a basic layout' do
54
- let(:layout) { :basic }
55
- specify 'applies radio to the container, and an inline label' do
56
- expect(form).to match %r{<div class="radio"><label><input.+? /> Jeremy</label></div>}
57
- end
58
- end
59
-
60
- describe 'given a horizontal layout' do
61
- let(:layout) { :horizontal }
62
- specify 'applies form-group to the outer container, .col-sm-offset-3.col-sm-9 to the field container, radio to the container, and an inline label' do
63
- expect(form).to match %r{<div class="form-group"><div class="col-sm-offset-3 col-sm-9"><div class="radio"><label><input.+? /> Jeremy</label></div></div></div>}
64
- end
65
- end
66
-
67
- describe 'given an inline layout' do
68
- let(:layout) { :inline }
69
- specify 'applies radio to the container, and an inline label' do
70
- expect(form).to match %r{<div class="radio"><label><input.+? /> Jeremy</label></div>}
71
- end
72
-
73
- context 'given a help message' do
74
- let(:options) { {help: 'Please select an option'} }
75
-
76
- specify 'applies sr-only to the help message' do
77
- expect(form).to include '<span class="help-block text-left sr-only">Please select an option</span>'
78
- end
79
- end
80
-
81
- context 'given an error' do
82
- before { user.errors.add :name, 'cannot be nil' }
83
-
84
- specify 'applies sr-only to the error message' do
85
- expect(form).to include '<span class="help-block text-left sr-only">cannot be nil</span>'
86
- end
87
- end
88
- end
89
- end
@@ -1,88 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'select' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for user, layout: layout, errors: errors, url: '/', &block }
8
- let(:user) { User.new }
9
- let(:errors) { {} }
10
- let(:block) { Proc.new {|f| f.select :name, [['Jeremy', 1]], options} }
11
- let(:options) { {} }
12
-
13
- context 'given any layout' do
14
- let(:layout) { :whatever }
15
-
16
- specify 'not given a label option, automatically generates one' do
17
- expect(form).to include 'Name</label>'
18
- end
19
-
20
- context 'given a label option, uses the provided one' do
21
- let(:options) { {label: 'Given name'} }
22
- it { expect(form).to include 'Given name</label>' }
23
- end
24
-
25
- context 'not given a help option, does not display a help box' do
26
- it { expect(form).not_to include 'help-block' }
27
- end
28
-
29
- context 'given a help option, displays a help box' do
30
- let(:options) { {help: 'Please select an option'} }
31
- it { expect(form).to include '<span class="help-block text-left">Please select an option</span>' }
32
- end
33
-
34
- specify 'not given an error, does not apply has-error to the form group' do
35
- expect(form).not_to include 'has-error'
36
- end
37
-
38
- context 'given an error' do
39
- before { user.errors.add :name, 'cannot be nil' }
40
-
41
- specify 'shows errors and error messages' do
42
- expect(form).to include 'has-error'
43
- expect(form).to include '<span class="help-block text-left">cannot be nil</span>'
44
- end
45
-
46
- specify 'does not show error icons' do
47
- expect(form).not_to include 'has-feedback'
48
- end
49
- end
50
- end
51
-
52
- describe 'given a basic layout' do
53
- let(:layout) { :basic }
54
- specify 'applies form-group to the container, form-control to the input' do
55
- expect(form).to match %r{<div class="form-group"><label.+?>Name</label><select class="form-control"}
56
- end
57
- end
58
-
59
- describe 'given a horizontal layout' do
60
- let(:layout) { :horizontal }
61
- specify 'applies form-group to the container, form-control to the input, col-sm-3.control-label to the label and col-sm-9 to the field container' do
62
- expect(form).to match %r{<div class="form-group"><label class="col-sm-3 control-label".+?>Name</label><div class="col-sm-9"><select class="form-control"}
63
- end
64
- end
65
-
66
- describe 'given an inline layout' do
67
- let(:layout) { :inline }
68
- specify 'applies form-group to the container, form-control to the input, sr-only to the label' do
69
- expect(form).to match %r{<div class="form-group"><label class="sr-only".+?>Name</label><select class="form-control"}
70
- end
71
-
72
- context 'given a help message' do
73
- let(:options) { {help: 'Please select an option'} }
74
-
75
- specify 'applies sr-only to the help message' do
76
- expect(form).to include '<span class="help-block text-left sr-only">Please select an option</span>'
77
- end
78
- end
79
-
80
- context 'given an error' do
81
- before { user.errors.add :name, 'cannot be nil' }
82
-
83
- specify 'applies sr-only to the error message' do
84
- expect(form).to include '<span class="help-block text-left sr-only">cannot be nil</span>'
85
- end
86
- end
87
- end
88
- end
@@ -1,67 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'static_control' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for User.new, layout: layout, url: '/', &block }
8
- let(:block) { Proc.new {|f| f.static_control 'user@example.com', options } }
9
- let(:options) { {} }
10
-
11
- context 'given any layout' do
12
- let(:layout) { :whatever }
13
-
14
- specify 'adds a paragraph with the static control' do
15
- expect(form).to include '<div class="form-group"'
16
- expect(form).to include '<p class="form-control-static">user@example.com</p>'
17
- end
18
-
19
- context 'given a label option, uses the provided one' do
20
- let(:options) { {label: 'Email'} }
21
- it { expect(form).to include 'Email</label>' }
22
- end
23
-
24
- context 'given the text as a block' do
25
- let(:block) { Proc.new {|f| f.static_control(label: 'Email') { 'user@example.com' } } }
26
-
27
- specify 'behaves in the same way' do
28
- expect(form).to include '<div class="form-group"'
29
- expect(form).to include '<p class="form-control-static">user@example.com</p>'
30
- expect(form).to include 'Email</label>'
31
- end
32
- end
33
- end
34
-
35
- describe 'given a basic layout and a label' do
36
- let(:layout) { :basic }
37
- let(:options) { {label: 'Email'} }
38
- specify 'uses the provided label' do
39
- expect(form).to include '<label>Email</label><p'
40
- end
41
- end
42
-
43
- describe 'given a horizontal layout' do
44
- let(:layout) { :horizontal }
45
-
46
- context 'and a label' do
47
- let(:options) { {label: 'Email'} }
48
-
49
- specify 'applies col-sm-9 to the field container and col-sm-3 to the label' do
50
- expect(form).to include '<label class="col-sm-3 control-label">Email</label><div class="col-sm-9"><p'
51
- end
52
- end
53
-
54
- specify 'and no label, applies col-sm-9.col-sm-offset-3 to the field container' do
55
- expect(form).to include '<div class="col-sm-9 col-sm-offset-3"><p'
56
- end
57
- end
58
-
59
- describe 'given an inline layout and a label' do
60
- let(:layout) { :inline }
61
- let(:options) { {label: 'Email'} }
62
-
63
- specify 'applies sr-only to the label' do
64
- expect(form).to include '<label class="sr-only">Email</label>'
65
- end
66
- end
67
- end
@@ -1,30 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'submit' do
6
- let(:protect_against_forgery?) { false }
7
- let(:form) { form_for User.new, layout: layout, url: '/', &block }
8
- let(:block) { Proc.new {|f| f.submit 'Save', options} }
9
- let(:options) { {} }
10
-
11
- context 'given any layout' do
12
- let(:layout) { :whatever }
13
-
14
- specify 'applies .btn.btn-primary to the button' do
15
- expect(form).to match %r{input.+? class="btn btn-primary"}
16
- end
17
-
18
- context 'given a context option, applies the context class' do
19
- let(:options) { {context: :info} }
20
- it { expect(form).to match %r{input.+? class="btn btn-info"} }
21
- end
22
- end
23
-
24
- describe 'given a horizontal layout' do
25
- let(:layout) { :horizontal }
26
- specify 'applies form-group to the container, col-sm-offset-3.col-sm-9 to the field container' do
27
- expect(form).to match %r{<div class="form-group"><div class="col-sm-offset-3 col-sm-9"><input}
28
- end
29
- end
30
- end
@@ -1,50 +0,0 @@
1
- require 'rails_helper'
2
- require 'bh/core_ext/rails/form_for_helper'
3
- include Bh::Rails::Helpers
4
-
5
- describe 'form_for' do
6
- let(:bh) { RailsView.new }
7
- let(:protect_against_forgery?) { false }
8
- attr_accessor :output_buffer
9
- let(:form) { form_for(:object, options.merge(url: '/')) {} }
10
- let(:options) { {} }
11
-
12
- specify 'by default, does not apply Bootstrap attributes to the form' do
13
- expect(form).not_to include 'role="form"'
14
- end
15
-
16
- specify 'wrapped in navbar, applies Bootstrap attributes of a navbar form' do
17
- bh.navbar { expect(form).to include 'role="form"' }
18
- bh.navbar { expect(form).to include 'class="navbar-form"' }
19
- end
20
-
21
- specify 'wrapped in nav, surrounds the form in a <li> item' do
22
- bh.nav { expect(form).to match %r{^<li><form.+?</form></li>$} }
23
- end
24
-
25
- describe 'with layout: :horizontal' do
26
- let(:options) { {layout: :horizontal} }
27
-
28
- specify 'applies Bootstrap attributes of an horizontal form' do
29
- expect(form).to include 'role="form"'
30
- expect(form).to include 'class="form-horizontal"'
31
- end
32
- end
33
-
34
- describe 'with layout: :inline' do
35
- let(:options) { {layout: :inline} }
36
-
37
- specify 'applies Bootstrap attributes of an inline form' do
38
- expect(form).to include 'role="form"'
39
- expect(form).to include 'class="form-inline"'
40
- end
41
- end
42
-
43
- describe 'with any other value for :layout' do
44
- let(:options) { {layout: :basic} }
45
-
46
- specify 'applies Bootstrap attributes of a basic form' do
47
- expect(form).to include 'role="form"'
48
- end
49
- end
50
- end
@@ -1,12 +0,0 @@
1
- shared_examples_for 'the link_to helper (Rails)' do
2
- all_tests_pass_with 'no link_to caption (Rails)'
3
- end
4
-
5
- #--
6
-
7
- shared_examples_for 'no link_to caption (Rails)' do
8
- specify 'uses the original link_to helper which sets the link to the caption' do
9
- html = '<a href="/">/</a>'
10
- expect(link_to: :nil_name).to generate html
11
- end
12
- end
data/spec/rails_helper.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class User
4
- require 'active_model'
5
-
6
- include ActiveModel::Validations
7
- include ActiveModel::Conversion
8
- extend ActiveModel::Naming
9
-
10
- attr_accessor :name
11
-
12
- def initialize(attributes = {})
13
- @name = attributes[:name]
14
- end
15
-
16
- def persisted?
17
- false
18
- end
19
- end
20
-
21
- require 'action_view'
22
- include ActionView::Helpers::FormOptionsHelper
23
- include defined?(ActionView::VERSION) ? ActionView::RecordIdentifier : ActionController::RecordIdentifier
24
- I18n.enforce_available_locales = true
data/spec/rails_spec.rb DELETED
@@ -1,29 +0,0 @@
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 (Rails)'
28
- all_tests_pass_for 'the link_to helper'
29
- end
@@ -1,62 +0,0 @@
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">&times;</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">&times;</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