formtastic 2.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +1 -0
- data/.github/workflows/test.yml +61 -0
- data/.gitignore +4 -2
- data/CHANGELOG.md +52 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +105 -0
- data/MIT-LICENSE +1 -1
- data/{README.textile → README.md} +204 -219
- data/RELEASE_PROCESS +3 -1
- data/Rakefile +27 -29
- data/app/assets/stylesheets/formtastic.css +3 -2
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +11 -14
- data/gemfiles/rails_5.2/Gemfile +5 -0
- data/gemfiles/rails_6.0/Gemfile +5 -0
- data/gemfiles/rails_6.1/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +13 -0
- data/lib/formtastic/action_class_finder.rb +18 -0
- data/lib/formtastic/actions/button_action.rb +55 -60
- data/lib/formtastic/actions/input_action.rb +59 -57
- data/lib/formtastic/actions/link_action.rb +68 -67
- data/lib/formtastic/actions.rb +6 -3
- data/lib/formtastic/deprecation.rb +5 -0
- data/lib/formtastic/engine.rb +3 -1
- data/lib/formtastic/form_builder.rb +35 -16
- data/lib/formtastic/helpers/action_helper.rb +34 -28
- data/lib/formtastic/helpers/enum.rb +13 -0
- data/lib/formtastic/helpers/errors_helper.rb +2 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +16 -12
- data/lib/formtastic/helpers/form_helper.rb +19 -16
- data/lib/formtastic/helpers/input_helper.rb +69 -97
- data/lib/formtastic/helpers/inputs_helper.rb +35 -25
- data/lib/formtastic/helpers/reflection.rb +4 -4
- data/lib/formtastic/helpers.rb +1 -2
- data/lib/formtastic/html_attributes.rb +12 -1
- data/lib/formtastic/i18n.rb +1 -1
- data/lib/formtastic/input_class_finder.rb +18 -0
- data/lib/formtastic/inputs/base/choices.rb +2 -2
- data/lib/formtastic/inputs/base/collections.rb +46 -14
- data/lib/formtastic/inputs/base/database.rb +7 -2
- data/lib/formtastic/inputs/base/datetime_pickerish.rb +85 -0
- data/lib/formtastic/inputs/base/errors.rb +7 -7
- data/lib/formtastic/inputs/base/hints.rb +2 -2
- data/lib/formtastic/inputs/base/html.rb +10 -9
- data/lib/formtastic/inputs/base/labelling.rb +5 -8
- data/lib/formtastic/inputs/base/naming.rb +4 -4
- data/lib/formtastic/inputs/base/numeric.rb +1 -1
- data/lib/formtastic/inputs/base/options.rb +3 -4
- data/lib/formtastic/inputs/base/stringish.rb +10 -2
- data/lib/formtastic/inputs/base/timeish.rb +34 -22
- data/lib/formtastic/inputs/base/validations.rb +41 -13
- data/lib/formtastic/inputs/base/wrapping.rb +29 -26
- data/lib/formtastic/inputs/base.rb +22 -15
- data/lib/formtastic/inputs/boolean_input.rb +26 -12
- data/lib/formtastic/inputs/check_boxes_input.rb +39 -31
- data/lib/formtastic/inputs/color_input.rb +41 -0
- data/lib/formtastic/inputs/country_input.rb +24 -5
- data/lib/formtastic/inputs/datalist_input.rb +41 -0
- data/lib/formtastic/inputs/date_picker_input.rb +93 -0
- data/lib/formtastic/inputs/{date_input.rb → date_select_input.rb} +1 -1
- data/lib/formtastic/inputs/datetime_picker_input.rb +103 -0
- data/lib/formtastic/inputs/{datetime_input.rb → datetime_select_input.rb} +1 -1
- data/lib/formtastic/inputs/file_input.rb +2 -2
- data/lib/formtastic/inputs/hidden_input.rb +2 -6
- data/lib/formtastic/inputs/radio_input.rb +28 -22
- data/lib/formtastic/inputs/select_input.rb +36 -39
- data/lib/formtastic/inputs/time_picker_input.rb +99 -0
- data/lib/formtastic/inputs/{time_input.rb → time_select_input.rb} +6 -2
- data/lib/formtastic/inputs/time_zone_input.rb +16 -6
- data/lib/formtastic/inputs.rb +32 -21
- data/lib/formtastic/localized_string.rb +1 -1
- data/lib/formtastic/localizer.rb +24 -24
- data/lib/formtastic/namespaced_class_finder.rb +99 -0
- data/lib/formtastic/version.rb +1 -1
- data/lib/formtastic.rb +20 -10
- data/lib/generators/formtastic/form/form_generator.rb +10 -4
- data/lib/generators/formtastic/input/input_generator.rb +46 -0
- data/lib/generators/formtastic/install/install_generator.rb +5 -19
- data/lib/generators/templates/_form.html.slim +2 -2
- data/lib/generators/templates/formtastic.rb +46 -25
- data/lib/generators/templates/input.rb +19 -0
- data/sample/basic_inputs.html +23 -3
- data/script/integration-template.rb +74 -0
- data/script/integration.sh +19 -0
- data/spec/action_class_finder_spec.rb +12 -0
- data/spec/actions/button_action_spec.rb +8 -8
- data/spec/actions/generic_action_spec.rb +92 -56
- data/spec/actions/input_action_spec.rb +7 -7
- data/spec/actions/link_action_spec.rb +10 -10
- data/spec/builder/custom_builder_spec.rb +36 -20
- data/spec/builder/error_proc_spec.rb +4 -4
- data/spec/builder/semantic_fields_for_spec.rb +28 -29
- data/spec/fast_spec_helper.rb +12 -0
- data/spec/generators/formtastic/form/form_generator_spec.rb +45 -32
- data/spec/generators/formtastic/input/input_generator_spec.rb +124 -0
- data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
- data/spec/helpers/action_helper_spec.rb +75 -103
- data/spec/helpers/actions_helper_spec.rb +17 -17
- data/spec/helpers/form_helper_spec.rb +84 -33
- data/spec/helpers/input_helper_spec.rb +333 -285
- data/spec/helpers/inputs_helper_spec.rb +167 -121
- data/spec/helpers/reflection_helper_spec.rb +3 -3
- data/spec/helpers/semantic_errors_helper_spec.rb +23 -23
- data/spec/i18n_spec.rb +26 -26
- data/spec/input_class_finder_spec.rb +10 -0
- data/spec/inputs/base/collections_spec.rb +76 -0
- data/spec/inputs/base/validations_spec.rb +480 -0
- data/spec/inputs/boolean_input_spec.rb +100 -65
- data/spec/inputs/check_boxes_input_spec.rb +200 -101
- data/spec/inputs/color_input_spec.rb +85 -0
- data/spec/inputs/country_input_spec.rb +20 -20
- data/spec/inputs/custom_input_spec.rb +3 -4
- data/spec/inputs/datalist_input_spec.rb +61 -0
- data/spec/inputs/date_picker_input_spec.rb +449 -0
- data/spec/inputs/date_select_input_spec.rb +249 -0
- data/spec/inputs/datetime_picker_input_spec.rb +490 -0
- data/spec/inputs/datetime_select_input_spec.rb +209 -0
- data/spec/inputs/email_input_spec.rb +5 -5
- data/spec/inputs/file_input_spec.rb +6 -6
- data/spec/inputs/hidden_input_spec.rb +22 -35
- data/spec/inputs/include_blank_spec.rb +11 -11
- data/spec/inputs/label_spec.rb +62 -25
- data/spec/inputs/number_input_spec.rb +112 -112
- data/spec/inputs/password_input_spec.rb +5 -5
- data/spec/inputs/phone_input_spec.rb +5 -5
- data/spec/inputs/placeholder_spec.rb +6 -6
- data/spec/inputs/radio_input_spec.rb +99 -55
- data/spec/inputs/range_input_spec.rb +66 -66
- data/spec/inputs/readonly_spec.rb +50 -0
- data/spec/inputs/search_input_spec.rb +5 -5
- data/spec/inputs/select_input_spec.rb +170 -170
- data/spec/inputs/string_input_spec.rb +68 -16
- data/spec/inputs/text_input_spec.rb +16 -16
- data/spec/inputs/time_picker_input_spec.rb +455 -0
- data/spec/inputs/time_select_input_spec.rb +261 -0
- data/spec/inputs/time_zone_input_spec.rb +54 -28
- data/spec/inputs/url_input_spec.rb +5 -5
- data/spec/inputs/with_options_spec.rb +7 -7
- data/spec/localizer_spec.rb +39 -17
- data/spec/namespaced_class_finder_spec.rb +79 -0
- data/spec/schema.rb +21 -0
- data/spec/spec_helper.rb +254 -221
- data/spec/support/custom_macros.rb +128 -95
- data/spec/support/shared_examples.rb +12 -0
- data/spec/support/specialized_class_finder_shared_example.rb +27 -0
- data/spec/support/test_environment.rb +26 -10
- metadata +177 -238
- data/.travis.yml +0 -8
- data/Appraisals +0 -11
- data/CHANGELOG +0 -371
- data/gemfiles/rails-3.0.gemfile +0 -7
- data/gemfiles/rails-3.1.gemfile +0 -7
- data/gemfiles/rails-3.2.gemfile +0 -7
- data/lib/formtastic/helpers/buttons_helper.rb +0 -310
- data/lib/formtastic/inputs/base/grouped_collections.rb +0 -77
- data/lib/formtastic/util.rb +0 -25
- data/lib/tasks/verify_rcov.rb +0 -44
- data/spec/helpers/buttons_helper_spec.rb +0 -166
- data/spec/helpers/commit_button_helper_spec.rb +0 -530
- data/spec/inputs/date_input_spec.rb +0 -227
- data/spec/inputs/datetime_input_spec.rb +0 -185
- data/spec/inputs/time_input_spec.rb +0 -267
- data/spec/support/deferred_garbage_collection.rb +0 -21
@@ -1,72 +1,61 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
describe '
|
5
|
-
|
6
|
-
include FormtasticSpecHelper
|
7
|
-
|
8
|
-
before do
|
9
|
-
@output_buffer = ''
|
10
|
-
mock_everything
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
::I18n.backend.reload!
|
15
|
-
end
|
3
|
+
RSpec.describe 'with action class finder' do
|
4
|
+
include_context 'form builder'
|
16
5
|
|
17
6
|
describe 'arguments and options' do
|
18
7
|
|
19
8
|
it 'should require the first argument (the action method)' do
|
20
|
-
|
9
|
+
expect {
|
21
10
|
concat(semantic_form_for(@new_post) do |builder|
|
22
11
|
concat(builder.action()) # no args passed in at all
|
23
12
|
end)
|
24
|
-
}.
|
13
|
+
}.to raise_error(ArgumentError)
|
25
14
|
end
|
26
15
|
|
27
16
|
describe ':as option' do
|
28
|
-
|
17
|
+
|
29
18
|
describe 'when not provided' do
|
30
|
-
|
19
|
+
|
31
20
|
it 'should default to a commit for commit' do
|
32
21
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
33
22
|
concat(builder.action(:submit))
|
34
23
|
end)
|
35
|
-
output_buffer.
|
24
|
+
expect(output_buffer).to have_tag('form li.action.input_action', :count => 1)
|
36
25
|
end
|
37
|
-
|
26
|
+
|
38
27
|
it 'should default to a button for reset' do
|
39
28
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
40
29
|
concat(builder.action(:reset))
|
41
30
|
end)
|
42
|
-
output_buffer.
|
31
|
+
expect(output_buffer).to have_tag('form li.action.input_action', :count => 1)
|
43
32
|
end
|
44
33
|
|
45
34
|
it 'should default to a link for cancel' do
|
46
35
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
47
36
|
concat(builder.action(:cancel))
|
48
37
|
end)
|
49
|
-
output_buffer.
|
38
|
+
expect(output_buffer).to have_tag('form li.action.link_action', :count => 1)
|
50
39
|
end
|
51
40
|
end
|
52
|
-
|
41
|
+
|
53
42
|
it 'should call the corresponding action class with .to_html' do
|
54
43
|
[:input, :button, :link].each do |action_style|
|
55
44
|
semantic_form_for(:project, :url => "http://test.host") do |builder|
|
56
|
-
action_instance =
|
45
|
+
action_instance = double('Action instance')
|
57
46
|
action_class = "#{action_style.to_s}_action".classify
|
58
47
|
action_constant = "Formtastic::Actions::#{action_class}".constantize
|
59
|
-
|
60
|
-
action_constant.
|
61
|
-
action_instance.
|
62
|
-
|
48
|
+
|
49
|
+
expect(action_constant).to receive(:new).and_return(action_instance)
|
50
|
+
expect(action_instance).to receive(:to_html).and_return("some HTML")
|
51
|
+
|
63
52
|
concat(builder.action(:submit, :as => action_style))
|
64
53
|
end
|
65
54
|
end
|
66
55
|
end
|
67
|
-
|
56
|
+
|
68
57
|
end
|
69
|
-
|
58
|
+
|
70
59
|
#describe ':label option' do
|
71
60
|
#
|
72
61
|
# describe 'when provided' do
|
@@ -99,7 +88,7 @@ describe 'Formtastic::FormBuilder#action' do
|
|
99
88
|
# it 'should render a label with localized text and not apply the label_str_method' do
|
100
89
|
# with_config :label_str_method, :reverse do
|
101
90
|
# @localized_label_text = 'Localized title'
|
102
|
-
# @new_post.stub
|
91
|
+
# @new_post.stub(:meta_description)
|
103
92
|
# ::I18n.backend.store_translations :en,
|
104
93
|
# :formtastic => {
|
105
94
|
# :labels => {
|
@@ -132,7 +121,7 @@ describe 'Formtastic::FormBuilder#action' do
|
|
132
121
|
#
|
133
122
|
# describe 'and object is given' do
|
134
123
|
# it 'should delegate the label logic to class human attribute name and pass it down to the label tag' do
|
135
|
-
# @new_post.stub
|
124
|
+
# @new_post.stub(:meta_description) # a two word method name
|
136
125
|
# @new_post.class.should_receive(:human_attribute_name).with('meta_description').and_return('meta_description'.humanize)
|
137
126
|
#
|
138
127
|
# concat(semantic_form_for(@new_post) do |builder|
|
@@ -145,7 +134,7 @@ describe 'Formtastic::FormBuilder#action' do
|
|
145
134
|
# describe 'and object is given with label_str_method set to :capitalize' do
|
146
135
|
# it 'should capitalize method name, passing it down to the label tag' do
|
147
136
|
# with_config :label_str_method, :capitalize do
|
148
|
-
# @new_post.stub
|
137
|
+
# @new_post.stub(:meta_description)
|
149
138
|
#
|
150
139
|
# concat(semantic_form_for(@new_post) do |builder|
|
151
140
|
# concat(builder.input(:meta_description))
|
@@ -207,159 +196,142 @@ describe 'Formtastic::FormBuilder#action' do
|
|
207
196
|
#end
|
208
197
|
#
|
209
198
|
describe ':wrapper_html option' do
|
210
|
-
|
199
|
+
|
211
200
|
describe 'when provided' do
|
212
201
|
it 'should be passed down to the li tag' do
|
213
202
|
concat(semantic_form_for(@new_post) do |builder|
|
214
203
|
concat(builder.action(:submit, :wrapper_html => {:id => :another_id}))
|
215
204
|
end)
|
216
|
-
output_buffer.
|
205
|
+
expect(output_buffer).to have_tag("form li#another_id")
|
217
206
|
end
|
218
|
-
|
207
|
+
|
219
208
|
it 'should append given classes to li default classes' do
|
220
209
|
concat(semantic_form_for(@new_post) do |builder|
|
221
210
|
concat(builder.action(:submit, :wrapper_html => {:class => :another_class}))
|
222
211
|
end)
|
223
|
-
output_buffer.
|
224
|
-
output_buffer.
|
225
|
-
output_buffer.
|
212
|
+
expect(output_buffer).to have_tag("form li.action")
|
213
|
+
expect(output_buffer).to have_tag("form li.input_action")
|
214
|
+
expect(output_buffer).to have_tag("form li.another_class")
|
226
215
|
end
|
227
|
-
|
216
|
+
|
228
217
|
it 'should allow classes to be an array' do
|
229
218
|
concat(semantic_form_for(@new_post) do |builder|
|
230
219
|
concat(builder.action(:submit, :wrapper_html => {:class => [ :my_class, :another_class ]}))
|
231
220
|
end)
|
232
|
-
output_buffer.
|
233
|
-
output_buffer.
|
234
|
-
output_buffer.
|
235
|
-
output_buffer.
|
221
|
+
expect(output_buffer).to have_tag("form li.action")
|
222
|
+
expect(output_buffer).to have_tag("form li.input_action")
|
223
|
+
expect(output_buffer).to have_tag("form li.my_class")
|
224
|
+
expect(output_buffer).to have_tag("form li.another_class")
|
236
225
|
end
|
237
226
|
end
|
238
|
-
|
227
|
+
|
239
228
|
describe 'when not provided' do
|
240
229
|
it 'should use default id and class' do
|
241
230
|
concat(semantic_form_for(@new_post) do |builder|
|
242
231
|
concat(builder.action(:submit))
|
243
232
|
end)
|
244
|
-
output_buffer.
|
245
|
-
output_buffer.
|
246
|
-
output_buffer.
|
233
|
+
expect(output_buffer).to have_tag("form li#post_submit_action")
|
234
|
+
expect(output_buffer).to have_tag("form li.action")
|
235
|
+
expect(output_buffer).to have_tag("form li.input_action")
|
247
236
|
end
|
248
237
|
end
|
249
|
-
|
238
|
+
|
250
239
|
end
|
251
|
-
|
240
|
+
|
252
241
|
end
|
253
242
|
|
254
243
|
describe 'instantiating an action class' do
|
255
|
-
|
256
244
|
context 'when a class does not exist' do
|
257
245
|
it "should raise an error" do
|
258
|
-
|
246
|
+
expect {
|
259
247
|
concat(semantic_form_for(@new_post) do |builder|
|
260
248
|
builder.action(:submit, :as => :non_existant)
|
261
249
|
end)
|
262
|
-
}.
|
250
|
+
}.to raise_error(Formtastic::UnknownActionError)
|
263
251
|
end
|
264
252
|
end
|
265
|
-
|
253
|
+
|
266
254
|
context 'when a customized top-level class does not exist' do
|
267
|
-
|
268
255
|
it 'should instantiate the Formtastic action' do
|
269
|
-
action =
|
270
|
-
Formtastic::Actions::ButtonAction.
|
256
|
+
action = double('action', :to_html => 'some HTML')
|
257
|
+
expect(Formtastic::Actions::ButtonAction).to receive(:new).and_return(action)
|
271
258
|
concat(semantic_form_for(@new_post) do |builder|
|
272
259
|
builder.action(:commit, :as => :button)
|
273
260
|
end)
|
274
261
|
end
|
275
|
-
|
276
262
|
end
|
277
|
-
|
263
|
+
|
278
264
|
describe 'when a top-level (custom) action class exists' do
|
279
265
|
it "should instantiate the top-level action instead of the Formtastic one" do
|
280
266
|
class ::ButtonAction < Formtastic::Actions::ButtonAction
|
281
267
|
end
|
282
|
-
|
283
|
-
action =
|
284
|
-
Formtastic::Actions::ButtonAction.
|
285
|
-
::ButtonAction.
|
286
|
-
|
268
|
+
|
269
|
+
action = double('action', :to_html => 'some HTML')
|
270
|
+
expect(Formtastic::Actions::ButtonAction).not_to receive(:new)
|
271
|
+
expect(::ButtonAction).to receive(:new).and_return(action)
|
272
|
+
|
287
273
|
concat(semantic_form_for(@new_post) do |builder|
|
288
274
|
builder.action(:commit, :as => :button)
|
289
275
|
end)
|
290
276
|
end
|
291
277
|
end
|
292
|
-
|
293
|
-
describe 'when instantiated multiple times with the same action type' do
|
294
|
-
|
295
|
-
it "should be cached (not calling the internal methods)" do
|
296
|
-
# TODO this is really tied to the underlying implementation
|
297
|
-
concat(semantic_form_for(@new_post) do |builder|
|
298
|
-
builder.should_receive(:custom_action_class_name).with(:button).once.and_return(::Formtastic::Actions::ButtonAction)
|
299
|
-
builder.action(:submit, :as => :button)
|
300
|
-
builder.action(:submit, :as => :button)
|
301
|
-
end)
|
302
|
-
end
|
303
|
-
|
304
|
-
end
|
305
|
-
|
278
|
+
|
306
279
|
describe 'support for :as on each action' do
|
307
|
-
|
280
|
+
|
308
281
|
it "should raise an error when the action does not support the :as" do
|
309
|
-
|
282
|
+
expect {
|
310
283
|
concat(semantic_form_for(@new_post) do |builder|
|
311
284
|
concat(builder.action(:submit, :as => :link))
|
312
285
|
end)
|
313
|
-
}.
|
314
|
-
|
315
|
-
|
286
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
287
|
+
|
288
|
+
expect {
|
316
289
|
concat(semantic_form_for(@new_post) do |builder|
|
317
290
|
concat(builder.action(:cancel, :as => :input))
|
318
291
|
end)
|
319
|
-
}.
|
320
|
-
|
321
|
-
|
292
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
293
|
+
|
294
|
+
expect {
|
322
295
|
concat(semantic_form_for(@new_post) do |builder|
|
323
296
|
concat(builder.action(:cancel, :as => :button))
|
324
297
|
end)
|
325
|
-
}.
|
298
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
326
299
|
end
|
327
|
-
|
300
|
+
|
328
301
|
it "should not raise an error when the action does not support the :as" do
|
329
|
-
|
302
|
+
expect {
|
330
303
|
concat(semantic_form_for(@new_post) do |builder|
|
331
304
|
concat(builder.action(:cancel, :as => :link))
|
332
305
|
end)
|
333
|
-
}.
|
334
|
-
|
335
|
-
|
306
|
+
}.not_to raise_error
|
307
|
+
|
308
|
+
expect {
|
336
309
|
concat(semantic_form_for(@new_post) do |builder|
|
337
310
|
concat(builder.action(:submit, :as => :input))
|
338
311
|
end)
|
339
|
-
}.
|
312
|
+
}.not_to raise_error
|
340
313
|
|
341
|
-
|
314
|
+
expect {
|
342
315
|
concat(semantic_form_for(@new_post) do |builder|
|
343
316
|
concat(builder.action(:submit, :as => :button))
|
344
317
|
end)
|
345
|
-
}.
|
346
|
-
|
347
|
-
|
318
|
+
}.not_to raise_error
|
319
|
+
|
320
|
+
expect {
|
348
321
|
concat(semantic_form_for(@new_post) do |builder|
|
349
322
|
concat(builder.action(:reset, :as => :input))
|
350
323
|
end)
|
351
|
-
}.
|
352
|
-
|
353
|
-
|
324
|
+
}.not_to raise_error
|
325
|
+
|
326
|
+
expect {
|
354
327
|
concat(semantic_form_for(@new_post) do |builder|
|
355
328
|
concat(builder.action(:reset, :as => :button))
|
356
329
|
end)
|
357
|
-
}.
|
330
|
+
}.not_to raise_error
|
358
331
|
end
|
359
|
-
|
332
|
+
|
360
333
|
end
|
361
|
-
|
334
|
+
|
362
335
|
end
|
363
336
|
|
364
337
|
end
|
365
|
-
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'Formtastic::FormBuilder#actions' do
|
4
|
+
RSpec.describe 'Formtastic::FormBuilder#actions' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -21,19 +21,19 @@ describe 'Formtastic::FormBuilder#actions' do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should render a fieldset inside the form, with a class of "actions"' do
|
24
|
-
output_buffer.
|
24
|
+
expect(output_buffer).to have_tag("form fieldset.actions")
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should render an ol inside the fieldset' do
|
28
|
-
output_buffer.
|
28
|
+
expect(output_buffer).to have_tag("form fieldset.actions ol")
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should render the contents of the block inside the ol' do
|
32
|
-
output_buffer.
|
32
|
+
expect(output_buffer).to have_tag("form fieldset.actions ol", :text => /hello/)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should not render a legend inside the fieldset' do
|
36
|
-
output_buffer.
|
36
|
+
expect(output_buffer).not_to have_tag("form fieldset.actions legend")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -47,7 +47,7 @@ describe 'Formtastic::FormBuilder#actions' do
|
|
47
47
|
end)
|
48
48
|
end
|
49
49
|
it 'should render a fieldset inside the form' do
|
50
|
-
output_buffer.
|
50
|
+
expect(output_buffer).to have_tag("form fieldset.actions legend", :text => /#{@legend_text}/)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -62,8 +62,8 @@ describe 'Formtastic::FormBuilder#actions' do
|
|
62
62
|
end)
|
63
63
|
end
|
64
64
|
it 'should pass the options into the fieldset tag as attributes' do
|
65
|
-
output_buffer.
|
66
|
-
output_buffer.
|
65
|
+
expect(output_buffer).to have_tag("form fieldset##{@id_option}")
|
66
|
+
expect(output_buffer).to have_tag("form fieldset.#{@class_option}")
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -80,23 +80,23 @@ describe 'Formtastic::FormBuilder#actions' do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should render a form' do
|
83
|
-
output_buffer.
|
83
|
+
expect(output_buffer).to have_tag('form')
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'should render an actions fieldset inside the form' do
|
87
|
-
output_buffer.
|
87
|
+
expect(output_buffer).to have_tag('form fieldset.actions')
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'should not render a legend in the fieldset' do
|
91
|
-
output_buffer.
|
91
|
+
expect(output_buffer).not_to have_tag('form fieldset.actions legend')
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'should render an ol in the fieldset' do
|
95
|
-
output_buffer.
|
95
|
+
expect(output_buffer).to have_tag('form fieldset.actions ol')
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should render a list item in the ol for each default action' do
|
99
|
-
output_buffer.
|
99
|
+
expect(output_buffer).to have_tag('form fieldset.actions ol li.action.input_action', :count => 1)
|
100
100
|
end
|
101
101
|
|
102
102
|
end
|
@@ -110,7 +110,7 @@ describe 'Formtastic::FormBuilder#actions' do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'should render a form with a fieldset containing a list item for each button arg' do
|
113
|
-
output_buffer.
|
113
|
+
expect(output_buffer).to have_tag('form > fieldset.actions > ol > li.action', :count => 3)
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
@@ -124,15 +124,15 @@ describe 'Formtastic::FormBuilder#actions' do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'should render a form with a fieldset containing a list item for each button arg' do
|
127
|
-
output_buffer.
|
127
|
+
expect(output_buffer).to have_tag('form > fieldset.actions > ol > li.action', :count => 3)
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'should pass the options down to the fieldset' do
|
131
|
-
output_buffer.
|
131
|
+
expect(output_buffer).to have_tag('form > fieldset#my-id.actions')
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'should use the special :name option as a text for the legend tag' do
|
135
|
-
output_buffer.
|
135
|
+
expect(output_buffer).to have_tag('form > fieldset#my-id.actions > legend', :text => /Now click a button/)
|
136
136
|
end
|
137
137
|
|
138
138
|
end
|