comfy_bootstrap_form 4.0.0.beta2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,114 @@
1
+ require_relative "../test_helper"
2
+
3
+ class BootstrapOptionsTest < ActionView::TestCase
4
+
5
+ setup do
6
+ options = { bootstrap: {
7
+ layout: "horizontal",
8
+ label: { hide: true }
9
+ } }
10
+ @builder = BootstrapForm::FormBuilder.new(:user, nil, self, options)
11
+ end
12
+
13
+ def test_defaults
14
+ options = BootstrapForm::BootstrapOptions.new
15
+ assert_equal "vertical", options.layout
16
+ assert_equal "col-sm-2", options.label_col_class
17
+ assert_equal "col-sm-10", options.control_col_class
18
+ assert_equal "text-sm-right", options.label_align_class
19
+ assert_equal "mr-sm-2", options.inline_margin_class
20
+ assert_equal ({}), options.label
21
+ assert_nil options.append
22
+ assert_nil options.prepend
23
+ assert_nil options.help
24
+ refute options.check_inline
25
+ end
26
+
27
+ def test_with_set_options
28
+ options = BootstrapForm::BootstrapOptions.new(
29
+ layout: "horizontal",
30
+ label_col_class: "col-md-4",
31
+ control_col_class: "col-md-8",
32
+ label_align_class: "text-md-left",
33
+ inline_margin_class: "mr-md-4",
34
+ label: { text: "test" },
35
+ append: "a",
36
+ prepend: "z",
37
+ help: "help text",
38
+ check_inline: "true"
39
+ )
40
+ assert_equal "horizontal", options.layout
41
+ assert_equal "col-md-4", options.label_col_class
42
+ assert_equal "col-md-8", options.control_col_class
43
+ assert_equal "text-md-left", options.label_align_class
44
+ assert_equal "mr-md-4", options.inline_margin_class
45
+ assert_equal ({ text: "test" }), options.label
46
+ assert_equal "a", options.append
47
+ assert_equal "z", options.prepend
48
+ assert_equal "help text", options.help
49
+ assert options.check_inline
50
+ end
51
+
52
+ def test_with_set_invalid_options
53
+ options = BootstrapForm::BootstrapOptions.new(invalid: "invalid")
54
+ refute options.respond_to?(:invalid)
55
+ end
56
+
57
+ def test_horizontal
58
+ options = BootstrapForm::BootstrapOptions.new
59
+ refute options.horizontal?
60
+
61
+ options = BootstrapForm::BootstrapOptions.new(layout: "horizontal")
62
+ assert options.horizontal?
63
+ end
64
+
65
+ def test_inline
66
+ options = BootstrapForm::BootstrapOptions.new
67
+ refute options.inline?
68
+
69
+ options = BootstrapForm::BootstrapOptions.new(layout: "inline")
70
+ assert options.inline?
71
+ end
72
+
73
+ def test_offset_col_class
74
+ options = BootstrapForm::BootstrapOptions.new
75
+ assert_equal "offset-sm-2", options.offset_col_class
76
+
77
+ options = BootstrapForm::BootstrapOptions.new(label_col_class: "col-md-4")
78
+ assert_equal "offset-md-4", options.offset_col_class
79
+ end
80
+
81
+ def scoped
82
+ options = BootstrapForm::BootstrapOptions.new
83
+ refute options.horizontal?
84
+
85
+ scoped_options = options.scoped(layout: "vertical")
86
+ assert scoped_options.horizontal?
87
+ refute options.horizontal?
88
+ end
89
+
90
+ def test_form_fields_global_options
91
+ actual = @builder.text_field :email
92
+ expected = <<-HTML
93
+ <div class="form-group row">
94
+ <label class="sr-only col-form-label col-sm-2 text-sm-right" for="user_email">Email</label>
95
+ <div class="col-sm-10 offset-sm-2">
96
+ <input class="form-control" id="user_email" name="user[email]" type="text"/>
97
+ </div>
98
+ </div>
99
+ HTML
100
+ assert_xml_equal expected, actual
101
+ end
102
+
103
+ def test_form_fields_global_options_override
104
+ actual = @builder.text_field :email, bootstrap: { layout: "vertical" }
105
+ expected = <<-HTML
106
+ <div class="form-group">
107
+ <label class="sr-only" for="user_email">Email</label>
108
+ <input class="form-control" id="user_email" name="user[email]" type="text"/>
109
+ </div>
110
+ HTML
111
+ assert_xml_equal expected, actual
112
+ end
113
+
114
+ end
@@ -19,7 +19,7 @@ class FieldsTest < ActionView::TestCase
19
19
  end
20
20
 
21
21
  def test_text_field_label_text
22
- actual = @builder.text_field(:email, bootstrap: {label: {text: "Custom Label"}})
22
+ actual = @builder.text_field(:email, bootstrap: { label: { text: "Custom Label" } })
23
23
  expected = <<-HTML
24
24
  <div class="form-group">
25
25
  <label for="user_email">Custom Label</label>
@@ -30,7 +30,7 @@ class FieldsTest < ActionView::TestCase
30
30
  end
31
31
 
32
32
  def test_text_field_label_css_class
33
- actual = @builder.text_field(:email, bootstrap: {label: {class: "custom_class"}})
33
+ actual = @builder.text_field(:email, bootstrap: { label: { class: "custom_class" } })
34
34
  expected = <<-HTML
35
35
  <div class="form-group">
36
36
  <label class="custom_class" for="user_email">Email</label>
@@ -41,7 +41,7 @@ class FieldsTest < ActionView::TestCase
41
41
  end
42
42
 
43
43
  def test_text_field_label_hide
44
- actual = @builder.text_field(:email, bootstrap: {label: {hide: true}})
44
+ actual = @builder.text_field(:email, bootstrap: { label: { hide: true } })
45
45
  expected = <<-HTML
46
46
  <div class="form-group">
47
47
  <label class="sr-only" for="user_email">Email</label>
@@ -63,7 +63,7 @@ class FieldsTest < ActionView::TestCase
63
63
  end
64
64
 
65
65
  def test_text_field_help_text
66
- actual = @builder.text_field(:email, bootstrap: {help: "help text"})
66
+ actual = @builder.text_field(:email, bootstrap: { help: "help text" })
67
67
  expected = <<-HTML
68
68
  <div class="form-group">
69
69
  <label for="user_email">Email</label>
@@ -289,7 +289,7 @@ class FieldsTest < ActionView::TestCase
289
289
  end
290
290
 
291
291
  def test_form_group_with_label
292
- actual = @builder.form_group(bootstrap: {label: {text: "Test"}}) do
292
+ actual = @builder.form_group(bootstrap: { label: { text: "Test" } }) do
293
293
  "test"
294
294
  end
295
295
  expected = <<-HTML
@@ -6,10 +6,10 @@ class FieldsWithErrorsTest < ActionView::TestCase
6
6
  @user = User.new
7
7
  @user.errors.add(:test, "invalid")
8
8
 
9
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
9
+ @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
10
10
 
11
11
  @original_proc = ActionView::Base.field_error_proc
12
- ActionView::Base.field_error_proc = proc { |input, instance| input }
12
+ ActionView::Base.field_error_proc = proc { |input, _instance| input }
13
13
  end
14
14
 
15
15
  teardown do
@@ -44,7 +44,7 @@ class FieldsWithErrorsTest < ActionView::TestCase
44
44
  end
45
45
 
46
46
  def test_collection_radio_buttons_with_error_and_help
47
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize, bootstrap: {help: "help text"})
47
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, bootstrap: { help: "help text" })
48
48
  expected = <<-HTML
49
49
  <fieldset class="form-group">
50
50
  <legend class="col-form-label pt-0">Test</legend>
@@ -64,10 +64,11 @@ class FieldsWithErrorsTest < ActionView::TestCase
64
64
  end
65
65
 
66
66
  def test_collection_radio_buttons_inline_with_error_and_help
67
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize, bootstrap: {
68
- inline: true,
69
- help: "help text"
70
- })
67
+ options = { bootstrap: {
68
+ check_inline: true,
69
+ help: "help text"
70
+ } }
71
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
71
72
  expected = <<-HTML
72
73
  <fieldset class="form-group">
73
74
  <legend class="col-form-label pt-0">Test</legend>
@@ -87,7 +88,7 @@ class FieldsWithErrorsTest < ActionView::TestCase
87
88
  end
88
89
 
89
90
  def test_text_field_with_input_group_error
90
- actual = @builder.text_field(:test, bootstrap: {prepend: "A", append: "Z"})
91
+ actual = @builder.text_field(:test, bootstrap: { prepend: "A", append: "Z", help: "help text" })
91
92
  expected = <<-HTML
92
93
  <div class="form-group">
93
94
  <label for="user_test">Test</label>
@@ -101,6 +102,7 @@ class FieldsWithErrorsTest < ActionView::TestCase
101
102
  </div>
102
103
  <div class="invalid-feedback">invalid</div>
103
104
  </div>
105
+ <small class="form-text text-muted">help text</small>
104
106
  </div>
105
107
  HTML
106
108
  assert_xml_equal expected, actual
@@ -4,46 +4,14 @@ class FormBuilderTest < ActionView::TestCase
4
4
 
5
5
  def test_initialization
6
6
  builder = BootstrapForm::FormBuilder.new(nil, nil, self, {})
7
-
8
- assert_equal "default", builder.bootstrap.layout
9
- assert_equal "col-sm-2", builder.bootstrap.label_col_class
10
- assert_equal "col-sm-10", builder.bootstrap.control_col_class
11
- assert_equal "text-sm-right", builder.bootstrap.label_align_class
12
- assert_equal "mr-sm-2", builder.bootstrap.inline_margin_class
13
-
14
- refute builder.bootstrap.horizontal?
15
-
16
- assert_equal "offset-sm-2", builder.bootstrap.offset_col_class
7
+ assert builder.form_bootstrap.is_a?(BootstrapForm::BootstrapOptions)
8
+ assert_equal "vertical", builder.form_bootstrap.layout
17
9
  end
18
10
 
19
11
  def test_initialization_with_options
20
- builder = BootstrapForm::FormBuilder.new(nil, nil, self, {
21
- skip_default_ids: true,
22
- bootstrap: {
23
- layout: "horizontal",
24
- label_col_class: "col-md-2",
25
- control_col_class: "col-md-10",
26
- label_align_class: "text-md-right",
27
- inline_margin_class: "mr-sm-2 mb-sm-2"
28
- }
29
- })
30
-
31
- assert_equal "horizontal", builder.bootstrap.layout
32
- assert_equal "col-md-2", builder.bootstrap.label_col_class
33
- assert_equal "col-md-10", builder.bootstrap.control_col_class
34
- assert_equal "text-md-right", builder.bootstrap.label_align_class
35
- assert_equal "mr-sm-2 mb-sm-2", builder.bootstrap.inline_margin_class
36
-
37
- assert builder.bootstrap.horizontal?
38
-
39
- assert_equal "offset-md-2", builder.bootstrap.offset_col_class
40
- end
41
-
42
- def test_initialization_for_inline
43
- builder = BootstrapForm::FormBuilder.new(nil, nil, self, {
44
- bootstrap: {layout: :inline}
45
- })
46
- assert builder.bootstrap.inline?
12
+ options = { bootstrap: { layout: "horizontal" } }
13
+ builder = BootstrapForm::FormBuilder.new(nil, nil, self, options)
14
+ assert_equal "horizontal", builder.form_bootstrap.layout
47
15
  end
48
16
 
49
17
  end
@@ -4,7 +4,7 @@ class HorizontalFormTest < ActionView::TestCase
4
4
 
5
5
  setup do
6
6
  @user = User.new
7
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {bootstrap: {layout: :horizontal}})
7
+ @builder = BootstrapForm::FormBuilder.new(:user, @user, self, bootstrap: { layout: :horizontal })
8
8
  end
9
9
 
10
10
  def test_text_field
@@ -21,7 +21,7 @@ class HorizontalFormTest < ActionView::TestCase
21
21
  end
22
22
 
23
23
  def test_text_field_with_no_label
24
- actual = @builder.text_field(:email, bootstrap: {label: {hide: true}})
24
+ actual = @builder.text_field(:email, bootstrap: { label: { hide: true } })
25
25
  expected = <<-HTML
26
26
  <div class="form-group row">
27
27
  <label class="sr-only col-form-label col-sm-2 text-sm-right" for="user_email">Email</label>
@@ -50,7 +50,7 @@ class HorizontalFormTest < ActionView::TestCase
50
50
  end
51
51
 
52
52
  def test_collection_radio_buttons
53
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize)
53
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize)
54
54
  expected = <<-HTML
55
55
  <fieldset class="form-group">
56
56
  <div class="row">
@@ -72,7 +72,7 @@ class HorizontalFormTest < ActionView::TestCase
72
72
  end
73
73
 
74
74
  def test_collection_check_boxes_with_no_label
75
- actual = @builder.collection_check_boxes(:test, ["a", "b"], :to_s, :titleize, bootstrap: {label: {hide: true}})
75
+ actual = @builder.collection_check_boxes(:test, %w[a b], :to_s, :titleize, bootstrap: { label: { hide: true } })
76
76
  expected = <<-HTML
77
77
  <input id="user_test" multiple="multiple" name="user[test][]" type="hidden" value=""/>
78
78
  <fieldset class="form-group">
@@ -106,11 +106,12 @@ class HorizontalFormTest < ActionView::TestCase
106
106
  end
107
107
 
108
108
  def test_input_group_with_options
109
- actual = @builder.text_field(:test, bootstrap: {
109
+ options = { bootstrap: {
110
110
  prepend: "prepend",
111
111
  append: "append",
112
112
  help: "help me"
113
- })
113
+ } }
114
+ actual = @builder.text_field(:test, options)
114
115
  expected = <<-HTML
115
116
  <div class="form-group row">
116
117
  <label class="col-form-label col-sm-2 text-sm-right" for="user_test">Test</label>
@@ -123,8 +124,8 @@ class HorizontalFormTest < ActionView::TestCase
123
124
  <div class="input-group-append">
124
125
  <span class="input-group-text">append</span>
125
126
  </div>
126
- <small class="form-text text-muted">help me</small>
127
127
  </div>
128
+ <small class="form-text text-muted">help me</small>
128
129
  </div>
129
130
  </div>
130
131
  HTML
@@ -144,7 +145,7 @@ class HorizontalFormTest < ActionView::TestCase
144
145
  end
145
146
 
146
147
  def test_form_group_with_label
147
- actual = @builder.form_group(bootstrap: {label: {text: "Test"}}) do
148
+ actual = @builder.form_group(bootstrap: { label: { text: "Test" } }) do
148
149
  "test"
149
150
  end
150
151
  expected = <<-HTML
@@ -4,7 +4,7 @@ class InlineFormTest < ActionView::TestCase
4
4
 
5
5
  setup do
6
6
  @user = User.new
7
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {bootstrap: {layout: :inline}})
7
+ @builder = BootstrapForm::FormBuilder.new(:user, @user, self, bootstrap: { layout: :inline })
8
8
  end
9
9
 
10
10
  def test_text_field
@@ -53,7 +53,7 @@ class InlineFormTest < ActionView::TestCase
53
53
  end
54
54
 
55
55
  def test_form_group_with_label
56
- actual = @builder.form_group(bootstrap: {label: {text: "Test"}}) do
56
+ actual = @builder.form_group(bootstrap: { label: { text: "Test" } }) do
57
57
  "test"
58
58
  end
59
59
  expected = <<-HTML
@@ -8,9 +8,11 @@ class InputGroupTest < ActionView::TestCase
8
8
  end
9
9
 
10
10
  def test_input_group
11
- actual = @builder.text_field(:test, bootstrap: {
12
- prepend: "prepend", append: "append"
13
- })
11
+ options = { bootstrap: {
12
+ prepend: "prepend",
13
+ append: "append"
14
+ } }
15
+ actual = @builder.text_field(:test, options)
14
16
  expected = <<-HTML
15
17
  <div class="form-group">
16
18
  <label for="user_test">Test</label>
@@ -29,10 +31,11 @@ class InputGroupTest < ActionView::TestCase
29
31
  end
30
32
 
31
33
  def test_input_group_with_html
32
- actual = @builder.text_field(:test, bootstrap: {
33
- prepend: {html: "<button>Go</button>".html_safe},
34
- append: {html: "<button>Stop</button>".html_safe}
35
- })
34
+ options = { bootstrap: {
35
+ prepend: { html: "<button>Go</button>".html_safe },
36
+ append: { html: "<button>Stop</button>".html_safe }
37
+ } }
38
+ actual = @builder.text_field(:test, options)
36
39
  expected = <<-HTML
37
40
  <div class="form-group">
38
41
  <label for="user_test">Test</label>
@@ -22,7 +22,7 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
22
22
  end
23
23
 
24
24
  def test_checkbox_with_label
25
- actual = @builder.check_box(:test, bootstrap: {label: {text: "Custom"}})
25
+ actual = @builder.check_box(:test, bootstrap: { label: { text: "Custom" } })
26
26
  expected = <<-HTML
27
27
  <fieldset class="form-group">
28
28
  <div class="form-check">
@@ -36,7 +36,7 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
36
36
  end
37
37
 
38
38
  def test_checkbox_with_help
39
- actual = @builder.check_box(:test, bootstrap: {help: "help me"})
39
+ actual = @builder.check_box(:test, bootstrap: { help: "help me" })
40
40
  expected = <<-HTML
41
41
  <fieldset class="form-group">
42
42
  <div class="form-check">
@@ -51,7 +51,7 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
51
51
  end
52
52
 
53
53
  def test_collection_check_boxes
54
- actual = @builder.collection_check_boxes(:test, ["a", "b"], :to_s, :titleize)
54
+ actual = @builder.collection_check_boxes(:test, %w[a b], :to_s, :titleize)
55
55
  expected = <<-HTML
56
56
  <input id="user_test" multiple="multiple" name="user[test][]" type="hidden" value=""/>
57
57
  <fieldset class="form-group">
@@ -70,7 +70,7 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
70
70
  end
71
71
 
72
72
  def test_collection_checkboxes_without_hidden_field
73
- actual = @builder.collection_check_boxes(:test, ["a", "b"], :to_s, :titleize, include_hidden: false)
73
+ actual = @builder.collection_check_boxes(:test, %w[a b], :to_s, :titleize, include_hidden: false)
74
74
  expected = <<-HTML
75
75
  <fieldset class="form-group">
76
76
  <legend class="col-form-label pt-0">Test</legend>
@@ -88,7 +88,7 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
88
88
  end
89
89
 
90
90
  def test_radio_buttons
91
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize)
91
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize)
92
92
  expected = <<-HTML
93
93
  <fieldset class="form-group">
94
94
  <legend class="col-form-label pt-0">Test</legend>
@@ -106,9 +106,8 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
106
106
  end
107
107
 
108
108
  def test_radio_buttons_inline
109
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize, bootstrap: {
110
- inline: true
111
- })
109
+ options = { bootstrap: { check_inline: true } }
110
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
112
111
  expected = <<-HTML
113
112
  <fieldset class="form-group">
114
113
  <legend class="col-form-label pt-0">Test</legend>
@@ -126,9 +125,8 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
126
125
  end
127
126
 
128
127
  def test_radio_buttons_custom_label
129
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize, bootstrap: {
130
- label: {text: "Custom"}
131
- })
128
+ options = { bootstrap: { label: { text: "Custom" } } }
129
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
132
130
  expected = <<-HTML
133
131
  <fieldset class="form-group">
134
132
  <legend class="col-form-label pt-0">Custom</legend>
@@ -146,9 +144,8 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
146
144
  end
147
145
 
148
146
  def test_radio_buttons_no_label
149
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize, bootstrap: {
150
- label: {hide: true}
151
- })
147
+ options = { bootstrap: { label: { hide: true } } }
148
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
152
149
  expected = <<-HTML
153
150
  <fieldset class="form-group">
154
151
  <div class="form-check">
@@ -165,9 +162,8 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
165
162
  end
166
163
 
167
164
  def test_radio_buttons_with_help
168
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize, bootstrap: {
169
- help: "help me"
170
- })
165
+ options = { bootstrap: { help: "help me" } }
166
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
171
167
  expected = <<-HTML
172
168
  <fieldset class="form-group">
173
169
  <legend class="col-form-label pt-0">Test</legend>
@@ -186,9 +182,11 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
186
182
  end
187
183
 
188
184
  def test_radio_buttons_with_inline_help
189
- actual = @builder.collection_radio_buttons(:test, ["a", "b"], :to_s, :titleize, bootstrap: {
190
- inline: true, help: "help me"
191
- })
185
+ options = { bootstrap: {
186
+ check_inline: true,
187
+ help: "help me"
188
+ } }
189
+ actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
192
190
  expected = <<-HTML
193
191
  <fieldset class="form-group">
194
192
  <legend class="col-form-label pt-0">Test</legend>
@@ -205,4 +203,5 @@ class RadiosAndCheckboxessTest < ActionView::TestCase
205
203
  HTML
206
204
  assert_xml_equal expected, actual
207
205
  end
206
+
208
207
  end
@@ -45,7 +45,7 @@ class SubmitTest < ActionView::TestCase
45
45
 
46
46
  def test_submit_with_block
47
47
  actual = @builder.submit do
48
- %{<a href="/" class="btn btn-link">Cancel</a>}.html_safe
48
+ %(<a href="/" class="btn btn-link">Cancel</a>).html_safe
49
49
  end
50
50
  expected = <<-HTML
51
51
  <div class="form-group">
@@ -5,7 +5,7 @@ class ViewHelpersTest < ActionView::TestCase
5
5
  include BootstrapForm::ViewHelper
6
6
 
7
7
  def test_bootstrap_form_with
8
- actual = bootstrap_form_with(url: "/test"){ }
8
+ actual = bootstrap_form_with(url: "/test") {}
9
9
  expected = <<-HTML
10
10
  <form action="/test" accept-charset="UTF-8" data-remote="true" method="post">
11
11
  <input name="utf8" type="hidden" value="&#x2713;" />
@@ -31,7 +31,7 @@ class ViewHelpersTest < ActionView::TestCase
31
31
  end
32
32
 
33
33
  def test_bootstrap_form_as_horizontal
34
- actual = bootstrap_form_with(url: "/test", bootstrap: {layout: :horizontal}) do |form|
34
+ actual = bootstrap_form_with(url: "/test", bootstrap: { layout: :horizontal }) do |form|
35
35
  form.text_field :value
36
36
  end
37
37
  expected = <<-HTML
@@ -49,7 +49,7 @@ class ViewHelpersTest < ActionView::TestCase
49
49
  end
50
50
 
51
51
  def test_bootstrap_form_with_inline
52
- actual = bootstrap_form_with(url: "/test", bootstrap: {layout: :inline}) do |form|
52
+ actual = bootstrap_form_with(url: "/test", bootstrap: { layout: :inline }) do |form|
53
53
  form.text_field :value
54
54
  form.submit
55
55
  end
@@ -5,6 +5,7 @@ gemspec path: "../../"
5
5
  gem "rails", "~> 5.2.0.rc1"
6
6
 
7
7
  group :test do
8
+ gem "rubocop", "~> 0.51.0", require: false
8
9
  gem "minitest"
9
10
  gem "diffy"
10
11
  gem "equivalent-xml"
data/test/test_helper.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
2
 
3
- require 'coveralls'
3
+ require "coveralls"
4
4
  Coveralls.wear!
5
5
 
6
- require 'diffy'
7
- require 'nokogiri'
8
- require 'equivalent-xml'
6
+ require "diffy"
7
+ require "nokogiri"
8
+ require "equivalent-xml"
9
9
 
10
10
  require_relative "../demo/config/environment.rb"
11
11
  require "rails/test_help"
@@ -20,7 +20,7 @@ class ActionView::TestCase
20
20
  actual_xml = Nokogiri::XML("<test-xml>\n#{actual}\n</test-xml>", &:noblanks)
21
21
 
22
22
  equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml)
23
- assert equivalent, lambda {
23
+ assert equivalent, -> {
24
24
  # using a lambda because diffing is expensive
25
25
  Diffy::Diff.new(
26
26
  sort_attributes(expected_xml.root).to_xml(indent: 2),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfy_bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Khabarov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-02-06 00:00:00.000000000 Z
12
+ date: 2018-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -34,6 +34,7 @@ extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
36
  - ".gitignore"
37
+ - ".rubocop.yml"
37
38
  - ".travis.yml"
38
39
  - CONTRIBUTING.md
39
40
  - Gemfile
@@ -76,14 +77,20 @@ files:
76
77
  - demo/config/spring.rb
77
78
  - demo/config/storage.yml
78
79
  - demo/db/schema.rb
80
+ - demo/form_preview_horizontal.png
81
+ - demo/form_preview_horizontal_with_errors.png
82
+ - demo/form_preview_inline.png
83
+ - demo/form_preview_vertical.png
79
84
  - demo/log/.keep
80
85
  - demo/package.json
81
86
  - demo/public/favicon.ico
82
87
  - lib/bootstrap_form.rb
88
+ - lib/bootstrap_form/bootstrap_options.rb
83
89
  - lib/bootstrap_form/form_builder.rb
84
90
  - lib/bootstrap_form/version.rb
85
91
  - lib/bootstrap_form/view_helper.rb
86
92
  - lib/comfy_bootstrap_form.rb
93
+ - test/bootstrap_form/bootstrap_options_test.rb
87
94
  - test/bootstrap_form/fields_test.rb
88
95
  - test/bootstrap_form/fields_with_errors_test.rb
89
96
  - test/bootstrap_form/form_builder_test.rb
@@ -110,9 +117,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
117
  version: 2.2.2
111
118
  required_rubygems_version: !ruby/object:Gem::Requirement
112
119
  requirements:
113
- - - ">"
120
+ - - ">="
114
121
  - !ruby/object:Gem::Version
115
- version: 1.3.1
122
+ version: '0'
116
123
  requirements: []
117
124
  rubyforge_project:
118
125
  rubygems_version: 2.7.4