formtastic 2.1.1 → 2.2.0.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +19 -1
  3. data/Appraisals +7 -0
  4. data/CHANGELOG +18 -0
  5. data/README.textile +14 -16
  6. data/formtastic.gemspec +1 -1
  7. data/gemfiles/rails-4.gemfile +8 -0
  8. data/lib/formtastic/form_builder.rb +0 -1
  9. data/lib/formtastic/helpers/input_helper.rb +12 -26
  10. data/lib/formtastic/inputs.rb +6 -0
  11. data/lib/formtastic/inputs/base.rb +16 -4
  12. data/lib/formtastic/inputs/base/datetime_pickerish.rb +85 -0
  13. data/lib/formtastic/inputs/base/stringish.rb +10 -2
  14. data/lib/formtastic/inputs/base/timeish.rb +17 -17
  15. data/lib/formtastic/inputs/base/wrapping.rb +25 -20
  16. data/lib/formtastic/inputs/boolean_input.rb +24 -1
  17. data/lib/formtastic/inputs/date_input.rb +5 -29
  18. data/lib/formtastic/inputs/date_picker_input.rb +93 -0
  19. data/lib/formtastic/inputs/date_select_input.rb +34 -0
  20. data/lib/formtastic/inputs/datetime_input.rb +6 -8
  21. data/lib/formtastic/inputs/datetime_picker_input.rb +100 -0
  22. data/lib/formtastic/inputs/datetime_select_input.rb +12 -0
  23. data/lib/formtastic/inputs/hidden_input.rb +1 -1
  24. data/lib/formtastic/inputs/radio_input.rb +1 -1
  25. data/lib/formtastic/inputs/select_input.rb +2 -5
  26. data/lib/formtastic/inputs/time_input.rb +4 -28
  27. data/lib/formtastic/inputs/time_picker_input.rb +99 -0
  28. data/lib/formtastic/inputs/time_select_input.rb +34 -0
  29. data/lib/formtastic/version.rb +1 -1
  30. data/lib/generators/templates/formtastic.rb +0 -8
  31. data/sample/basic_inputs.html +21 -1
  32. data/spec/builder/semantic_fields_for_spec.rb +1 -1
  33. data/spec/generators/formtastic/install/install_generator_spec.rb +1 -1
  34. data/spec/helpers/input_helper_spec.rb +20 -16
  35. data/spec/helpers/semantic_errors_helper_spec.rb +10 -10
  36. data/spec/inputs/custom_input_spec.rb +5 -2
  37. data/spec/inputs/date_picker_input_spec.rb +449 -0
  38. data/spec/inputs/{date_input_spec.rb → date_select_input_spec.rb} +34 -34
  39. data/spec/inputs/datetime_picker_input_spec.rb +490 -0
  40. data/spec/inputs/{datetime_input_spec.rb → datetime_select_input_spec.rb} +33 -33
  41. data/spec/inputs/deprecated_time_date_datetime_inputs_spec.rb +48 -0
  42. data/spec/inputs/hidden_input_spec.rb +21 -17
  43. data/spec/inputs/include_blank_spec.rb +3 -3
  44. data/spec/inputs/label_spec.rb +1 -1
  45. data/spec/inputs/placeholder_spec.rb +1 -1
  46. data/spec/inputs/select_input_spec.rb +22 -14
  47. data/spec/inputs/time_picker_input_spec.rb +455 -0
  48. data/spec/inputs/{time_input_spec.rb → time_select_input_spec.rb} +35 -35
  49. data/spec/spec_helper.rb +25 -1
  50. data/spec/support/custom_macros.rb +2 -2
  51. metadata +32 -21
  52. data/lib/formtastic/helpers/buttons_helper.rb +0 -310
  53. data/spec/helpers/buttons_helper_spec.rb +0 -166
  54. data/spec/helpers/commit_button_helper_spec.rb +0 -530
@@ -1,166 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'Formtastic::FormBuilder#buttons' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- end
12
-
13
- describe 'with a block' do
14
- describe 'when no options are provided' do
15
- before do
16
- with_deprecation_silenced do
17
- concat(semantic_form_for(@new_post) do |builder|
18
- buttons = builder.buttons do
19
- concat('hello')
20
- end
21
- concat(buttons)
22
- end)
23
- end
24
- end
25
-
26
- it 'should render a fieldset inside the form, with a class of "inputs"' do
27
- output_buffer.should have_tag("form fieldset.buttons")
28
- end
29
-
30
- it 'should render an ol inside the fieldset' do
31
- output_buffer.should have_tag("form fieldset.buttons ol")
32
- end
33
-
34
- it 'should render the contents of the block inside the ol' do
35
- output_buffer.should have_tag("form fieldset.buttons ol", /hello/)
36
- end
37
-
38
- it 'should not render a legend inside the fieldset' do
39
- output_buffer.should_not have_tag("form fieldset.buttons legend")
40
- end
41
- end
42
-
43
- describe 'when a :name option is provided' do
44
- before do
45
- @legend_text = "Advanced options"
46
-
47
- with_deprecation_silenced do
48
- concat(semantic_form_for(@new_post) do |builder|
49
- builder.buttons :name => @legend_text do
50
- end
51
- end)
52
- end
53
- end
54
-
55
- it 'should render a fieldset inside the form' do
56
- output_buffer.should have_tag("form fieldset legend", /#{@legend_text}/)
57
- end
58
-
59
- end
60
-
61
- describe 'when other options are provided' do
62
- before do
63
- @id_option = 'advanced'
64
- @class_option = 'wide'
65
-
66
- with_deprecation_silenced do
67
- concat(semantic_form_for(@new_post) do |builder|
68
- builder.buttons :id => @id_option, :class => @class_option do
69
- end
70
- end)
71
- end
72
- end
73
-
74
- it 'should pass the options into the fieldset tag as attributes' do
75
- output_buffer.should have_tag("form fieldset##{@id_option}")
76
- output_buffer.should have_tag("form fieldset.#{@class_option}")
77
- end
78
-
79
- end
80
-
81
- end
82
-
83
- describe 'without a block' do
84
-
85
- describe 'with no args (default buttons)' do
86
-
87
- before do
88
- with_deprecation_silenced do
89
- concat(semantic_form_for(@new_post) do |builder|
90
- concat(builder.buttons)
91
- end)
92
- end
93
- end
94
-
95
- it 'should render a form' do
96
- output_buffer.should have_tag('form')
97
- end
98
-
99
- it 'should render a buttons fieldset inside the form' do
100
- output_buffer.should have_tag('form fieldset.buttons')
101
- end
102
-
103
- it 'should not render a legend in the fieldset' do
104
- output_buffer.should_not have_tag('form fieldset.buttons legend')
105
- end
106
-
107
- it 'should render an ol in the fieldset' do
108
- output_buffer.should have_tag('form fieldset.buttons ol')
109
- end
110
-
111
- it 'should render a list item in the ol for each default button' do
112
- output_buffer.should have_tag('form fieldset.buttons ol li', :count => 1)
113
- end
114
-
115
- it 'should render a commit list item for the commit button' do
116
- output_buffer.should have_tag('form fieldset.buttons ol li.commit')
117
- end
118
-
119
- end
120
-
121
- describe 'with button names as args' do
122
-
123
- before do
124
- with_deprecation_silenced do
125
- concat(semantic_form_for(@new_post) do |builder|
126
- concat(builder.buttons(:commit))
127
- end)
128
- end
129
- end
130
-
131
- it 'should render a form with a fieldset containing a list item for each button arg' do
132
- output_buffer.should have_tag('form > fieldset.buttons > ol > li', :count => 1)
133
- output_buffer.should have_tag('form > fieldset.buttons > ol > li.commit')
134
- end
135
-
136
- end
137
-
138
- describe 'with button names as args and an options hash' do
139
-
140
- before do
141
- with_deprecation_silenced do
142
- concat(semantic_form_for(@new_post) do |builder|
143
- concat(builder.buttons(:commit, :name => "Now click a button", :id => "my-id"))
144
- end)
145
- end
146
- end
147
-
148
- it 'should render a form with a fieldset containing a list item for each button arg' do
149
- output_buffer.should have_tag('form > fieldset.buttons > ol > li', :count => 1)
150
- output_buffer.should have_tag('form > fieldset.buttons > ol > li.commit', :count => 1)
151
- end
152
-
153
- it 'should pass the options down to the fieldset' do
154
- output_buffer.should have_tag('form > fieldset#my-id.buttons')
155
- end
156
-
157
- it 'should use the special :name option as a text for the legend tag' do
158
- output_buffer.should have_tag('form > fieldset#my-id.buttons > legend', /Now click a button/)
159
- end
160
-
161
- end
162
-
163
- end
164
-
165
- end
166
-
@@ -1,530 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'Formtastic::FormBuilder#commit_button' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- end
12
-
13
- describe 'when the object responds to :persisted? (ActiveModel)' do
14
-
15
- before do
16
- @new_post.stub(:respond_to?).with(:to_model).and_return("X")
17
- @new_post.stub(:respond_to?).with(:persisted?).and_return(true)
18
- @new_post.stub(:respond_to?).with(:new_record?).and_return(false)
19
- end
20
-
21
- it 'should call :persisted?' do
22
- with_deprecation_silenced do
23
- with_config :i18n_lookups_by_default, false do
24
- @new_post.should_receive(:persisted?)
25
- @new_post.should_not_receive(:new_record?)
26
- semantic_form_for(@new_post) do |builder|
27
- concat(builder.commit_button)
28
- end
29
- end
30
- end
31
- end
32
-
33
- end
34
-
35
- describe 'when not persisted' do
36
-
37
- before do
38
- @new_post.stub(:respond_to?).with(:to_model).and_return("X")
39
- @new_post.stub(:respond_to?).with(:persisted?).and_return(false)
40
- @new_post.stub(:respond_to?).with(:new_record?).and_return(false)
41
- end
42
-
43
- it 'should have a submit button label' do
44
- with_deprecation_silenced do
45
- with_config :i18n_lookups_by_default, false do
46
- concat(semantic_form_for(@new_post) do |builder|
47
- concat(builder.commit_button)
48
- end)
49
- end
50
- end
51
-
52
- output_buffer.should have_tag('.commit input[@value="Submit Post"]')
53
- end
54
- end
55
-
56
- describe 'when used on any record' do
57
-
58
- before do
59
- @new_post.stub!(:new_record?).and_return(false)
60
- with_deprecation_silenced do
61
- concat(semantic_form_for(@new_post) do |builder|
62
- concat(builder.commit_button)
63
- end)
64
- end
65
- end
66
-
67
- it 'should render a commit li' do
68
- output_buffer.should have_tag('li.commit')
69
- end
70
-
71
- it 'should render a button li' do
72
- output_buffer.should have_tag('li.button')
73
- end
74
-
75
- it 'should render an input with a type attribute of "submit"' do
76
- output_buffer.should have_tag('li.commit input[@type="submit"]')
77
- end
78
-
79
- it 'should render an input with a name attribute of "commit"' do
80
- output_buffer.should have_tag('li.commit input[@name="commit"]')
81
- end
82
-
83
- it 'should pass options given in :button_html to the button' do
84
- @new_post.stub!(:new_record?).and_return(false)
85
- with_deprecation_silenced do
86
- concat(semantic_form_for(@new_post) do |builder|
87
- concat(builder.commit_button('text', :button_html => {:class => 'my_class', :id => 'my_id'}))
88
- end)
89
- end
90
-
91
- output_buffer.should have_tag('li.commit input#my_id')
92
- output_buffer.should have_tag('li.commit input.my_class')
93
- end
94
-
95
- end
96
-
97
- describe "its accesskey" do
98
-
99
- it 'should allow nil default' do
100
- with_config :default_commit_button_accesskey, nil do
101
- output_buffer.should_not have_tag('li.commit input[@accesskey]')
102
- end
103
- end
104
-
105
- it 'should use the default if set' do
106
- with_config :default_commit_button_accesskey, 's' do
107
- @new_post.stub!(:new_record?).and_return(false)
108
- with_deprecation_silenced do
109
- concat(semantic_form_for(@new_post) do |builder|
110
- concat(builder.commit_button('text', :button_html => {}))
111
- end)
112
- end
113
- output_buffer.should have_tag('li.commit input[@accesskey="s"]')
114
- end
115
- end
116
-
117
- it 'should use the value set in options over the default' do
118
- with_config :default_commit_button_accesskey, 's' do
119
- @new_post.stub!(:new_record?).and_return(false)
120
- with_deprecation_silenced do
121
- concat(semantic_form_for(@new_post) do |builder|
122
- concat(builder.commit_button('text', :accesskey => 'o'))
123
- end)
124
- end
125
- output_buffer.should_not have_tag('li.commit input[@accesskey="s"]')
126
- output_buffer.should have_tag('li.commit input[@accesskey="o"]')
127
- end
128
- end
129
-
130
- it 'should use the value set in button_html over options' do
131
- with_config :default_commit_button_accesskey, 's' do
132
- @new_post.stub!(:new_record?).and_return(false)
133
- with_deprecation_silenced do
134
- concat(semantic_form_for(@new_post) do |builder|
135
- concat(builder.commit_button('text', :accesskey => 'o', :button_html => {:accesskey => 't'}))
136
- end)
137
- end
138
- output_buffer.should_not have_tag('li.commit input[@accesskey="s"]')
139
- output_buffer.should_not have_tag('li.commit input[@accesskey="o"]')
140
- output_buffer.should have_tag('li.commit input[@accesskey="t"]')
141
- end
142
- end
143
-
144
- end
145
-
146
- describe 'when the first option is a string and the second is a hash' do
147
-
148
- before do
149
- @new_post.stub!(:new_record?).and_return(false)
150
- with_deprecation_silenced do
151
- concat(semantic_form_for(@new_post) do |builder|
152
- concat(builder.commit_button("a string", :button_html => { :class => "pretty"}))
153
- end)
154
- end
155
- end
156
-
157
- it "should render the string as the value of the button" do
158
- output_buffer.should have_tag('li input[@value="a string"]')
159
- end
160
-
161
- it "should deal with the options hash" do
162
- output_buffer.should have_tag('li input.pretty')
163
- end
164
-
165
- end
166
-
167
- describe 'when the first option is a hash' do
168
-
169
- before do
170
- @new_post.stub!(:new_record?).and_return(false)
171
- with_deprecation_silenced do
172
- concat(semantic_form_for(@new_post) do |builder|
173
- concat(builder.commit_button(:button_html => { :class => "pretty"}))
174
- end)
175
- end
176
- end
177
-
178
- it "should deal with the options hash" do
179
- output_buffer.should have_tag('li input.pretty')
180
- end
181
-
182
- end
183
-
184
- describe 'label' do
185
-
186
- # No object
187
- describe 'when used without object' do
188
- describe 'when explicit label is provided' do
189
- it 'should render an input with the explicitly specified label' do
190
- with_deprecation_silenced do
191
- concat(semantic_form_for(:post, :url => 'http://example.com') do |builder|
192
- concat(builder.commit_button("Click!"))
193
- end)
194
- end
195
- output_buffer.should have_tag('li.commit input[@value="Click!"][@class~="submit"]')
196
- end
197
- end
198
-
199
- describe 'when no explicit label is provided' do
200
- describe 'when no I18n-localized label is provided' do
201
- before do
202
- ::I18n.backend.store_translations :en, :formtastic => {:submit => 'Submit %{model}'}
203
- end
204
-
205
- after do
206
- ::I18n.backend.reload!
207
- end
208
-
209
- it 'should render an input with default I18n-localized label (fallback)' do
210
- with_deprecation_silenced do
211
- concat(semantic_form_for(:post, :url => 'http://example.com') do |builder|
212
- concat(builder.commit_button)
213
- end)
214
- end
215
- output_buffer.should have_tag('li.commit input[@value="Submit Post"][@class~="submit"]')
216
- end
217
- end
218
-
219
- describe 'when I18n-localized label is provided' do
220
- before do
221
- ::I18n.backend.store_translations :en,
222
- :formtastic => {
223
- :actions => {
224
- :submit => 'Custom Submit',
225
- }
226
- }
227
- end
228
-
229
- after do
230
- ::I18n.backend.reload!
231
- end
232
-
233
- it 'should render an input with localized label (I18n)' do
234
- with_config :i18n_lookups_by_default, true do
235
- ::I18n.backend.store_translations :en,
236
- :formtastic => {
237
- :actions => {
238
- :post => {
239
- :submit => 'Custom Submit %{model}'
240
- }
241
- }
242
- }
243
- with_deprecation_silenced do
244
- concat(semantic_form_for(:post, :url => 'http://example.com') do |builder|
245
- concat(builder.commit_button)
246
- end)
247
- end
248
- output_buffer.should have_tag(%Q{li.commit input[@value="Custom Submit Post"][@class~="submit"]})
249
- end
250
- end
251
-
252
- it 'should render an input with anoptional localized label (I18n) - if first is not set' do
253
- with_config :i18n_lookups_by_default, true do
254
- with_deprecation_silenced do
255
- concat(semantic_form_for(:post, :url => 'http://example.com') do |builder|
256
- concat(builder.commit_button)
257
- end)
258
- end
259
- output_buffer.should have_tag(%Q{li.commit input[@value="Custom Submit"][@class~="submit"]})
260
- end
261
- end
262
-
263
- end
264
- end
265
- end
266
-
267
- # New record
268
- describe 'when used on a new record' do
269
- before do
270
- @new_post.stub!(:new_record?).and_return(true)
271
- end
272
-
273
- describe 'when explicit label is provided' do
274
- it 'should render an input with the explicitly specified label' do
275
- with_deprecation_silenced do
276
- concat(semantic_form_for(@new_post) do |builder|
277
- concat(builder.commit_button("Click!"))
278
- end)
279
- end
280
- output_buffer.should have_tag('li.commit input[@value="Click!"][@class~="create"]')
281
- end
282
- end
283
-
284
- describe 'when no explicit label is provided' do
285
- describe 'when no I18n-localized label is provided' do
286
- before do
287
- ::I18n.backend.store_translations :en, :formtastic => {:create => 'Create %{model}'}
288
- end
289
-
290
- after do
291
- ::I18n.backend.reload!
292
- end
293
-
294
- it 'should render an input with default I18n-localized label (fallback)' do
295
- with_deprecation_silenced do
296
- concat(semantic_form_for(@new_post) do |builder|
297
- concat(builder.commit_button)
298
- end)
299
- end
300
- output_buffer.should have_tag('li.commit input[@value="Create Post"][@class~="create"]')
301
- end
302
- end
303
-
304
- describe 'when I18n-localized label is provided' do
305
- before do
306
- ::I18n.backend.store_translations :en,
307
- :formtastic => {
308
- :actions => {
309
- :create => 'Custom Create',
310
- }
311
- }
312
- end
313
-
314
- after do
315
- ::I18n.backend.reload!
316
- end
317
-
318
- it 'should render an input with localized label (I18n)' do
319
- with_config :i18n_lookups_by_default, true do
320
- ::I18n.backend.store_translations :en,
321
- :formtastic => {
322
- :actions => {
323
- :post => {
324
- :create => 'Custom Create %{model}'
325
- }
326
- }
327
- }
328
- with_deprecation_silenced do
329
- concat(semantic_form_for(@new_post) do |builder|
330
- concat(builder.commit_button)
331
- end)
332
- end
333
- output_buffer.should have_tag(%Q{li.commit input[@value="Custom Create Post"][@class~="create"]})
334
- end
335
- end
336
-
337
- it 'should render an input with anoptional localized label (I18n) - if first is not set' do
338
- with_config :i18n_lookups_by_default, true do
339
- with_deprecation_silenced do
340
- concat(semantic_form_for(@new_post) do |builder|
341
- concat(builder.commit_button)
342
- end)
343
- end
344
- output_buffer.should have_tag(%Q{li.commit input[@value="Custom Create"][@class~="create"]})
345
- end
346
- end
347
-
348
- end
349
- end
350
- end
351
-
352
- # Existing record
353
- describe 'when used on an existing record' do
354
- before do
355
- @new_post.stub!(:persisted?).and_return(true)
356
- end
357
-
358
- describe 'when explicit label is provided' do
359
- it 'should render an input with the explicitly specified label' do
360
- with_deprecation_silenced do
361
- concat(semantic_form_for(@new_post) do |builder|
362
- concat(builder.commit_button("Click!"))
363
- end)
364
- end
365
- output_buffer.should have_tag('li.commit input[@value="Click!"][@class~="update"]')
366
- end
367
- end
368
-
369
- describe 'when no explicit label is provided' do
370
- describe 'when no I18n-localized label is provided' do
371
- before do
372
- ::I18n.backend.store_translations :en, :formtastic => {:update => 'Save %{model}'}
373
- end
374
-
375
- after do
376
- ::I18n.backend.reload!
377
- end
378
-
379
- it 'should render an input with default I18n-localized label (fallback)' do
380
- with_deprecation_silenced do
381
- concat(semantic_form_for(@new_post) do |builder|
382
- concat(builder.commit_button)
383
- end)
384
- end
385
- output_buffer.should have_tag('li.commit input[@value="Save Post"][@class~="update"]')
386
- end
387
- end
388
-
389
- describe 'when I18n-localized label is provided' do
390
- before do
391
- ::I18n.backend.reload!
392
- ::I18n.backend.store_translations :en,
393
- :formtastic => {
394
- :actions => {
395
- :update => 'Custom Save',
396
- }
397
- }
398
- end
399
-
400
- after do
401
- ::I18n.backend.reload!
402
- end
403
-
404
- it 'should render an input with localized label (I18n)' do
405
- with_config :i18n_lookups_by_default, true do
406
- ::I18n.backend.store_translations :en,
407
- :formtastic => {
408
- :actions => {
409
- :post => {
410
- :update => 'Custom Save %{model}'
411
- }
412
- }
413
- }
414
- with_deprecation_silenced do
415
- concat(semantic_form_for(@new_post) do |builder|
416
- concat(builder.commit_button)
417
- end)
418
- end
419
- output_buffer.should have_tag(%Q{li.commit input[@value="Custom Save Post"][@class~="update"]})
420
- end
421
- end
422
-
423
- it 'should render an input with anoptional localized label (I18n) - if first is not set' do
424
- with_config :i18n_lookups_by_default, true do
425
- with_deprecation_silenced do
426
- concat(semantic_form_for(@new_post) do |builder|
427
- concat(builder.commit_button)
428
- end)
429
- end
430
- output_buffer.should have_tag(%Q{li.commit input[@value="Custom Save"][@class~="update"]})
431
- ::I18n.backend.store_translations :en, :formtastic => {}
432
- end
433
- end
434
-
435
- end
436
- end
437
- end
438
- end
439
-
440
- describe 'when the model is two words' do
441
- before do
442
- output_buffer = ''
443
- class ::UserPost
444
- extend ActiveModel::Naming if defined?(ActiveModel::Naming)
445
- include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
446
-
447
- def id
448
- end
449
-
450
- def persisted?
451
- end
452
-
453
- # Rails does crappy human_name
454
- def self.human_name
455
- "User post"
456
- end
457
- end
458
- @new_user_post = ::UserPost.new
459
-
460
- @new_user_post.stub!(:new_record?).and_return(true)
461
- with_deprecation_silenced do
462
- concat(semantic_form_for(@new_user_post, :url => '') do |builder|
463
- concat(builder.commit_button())
464
- end)
465
- end
466
- end
467
-
468
- it "should render the string as the value of the button" do
469
- output_buffer.should have_tag('li input[@value="Create User post"]')
470
- end
471
-
472
- end
473
-
474
- describe ':wrapper_html option' do
475
-
476
- describe 'when provided' do
477
- it 'should be passed down to the li tag' do
478
- with_deprecation_silenced do
479
- concat(semantic_form_for(@new_post) do |builder|
480
- concat(builder.commit_button('text', :wrapper_html => {:id => :another_id}))
481
- end)
482
- end
483
- output_buffer.should have_tag("form li#another_id")
484
- end
485
-
486
- it 'should append given classes to li default classes' do
487
- with_deprecation_silenced do
488
- concat(semantic_form_for(@new_post) do |builder|
489
- concat(builder.commit_button('text', :wrapper_html => {:class => :another_class}))
490
- end)
491
- end
492
- output_buffer.should have_tag("form li.commit")
493
- output_buffer.should have_tag("form li.another_class")
494
- end
495
-
496
- it 'should allow classes to be an array' do
497
- with_deprecation_silenced do
498
- concat(semantic_form_for(@new_post) do |builder|
499
- concat(builder.commit_button('text', :wrapper_html => {:class => [ :my_class, :another_class ]}))
500
- end)
501
- end
502
- output_buffer.should have_tag("form li.commit")
503
- output_buffer.should have_tag("form li.my_class")
504
- output_buffer.should have_tag("form li.another_class")
505
- end
506
- end
507
-
508
- describe 'when not provided' do
509
- it 'should use default class' do
510
- with_deprecation_silenced do
511
- concat(semantic_form_for(@new_post) do |builder|
512
- concat(builder.commit_button('text'))
513
- end)
514
- end
515
- output_buffer.should have_tag("form li.commit.button")
516
- end
517
-
518
- it 'should use default id' do
519
- with_deprecation_silenced do
520
- concat(semantic_form_for(@new_post) do |builder|
521
- concat(builder.commit_button('text'))
522
- end)
523
- end
524
- output_buffer.should have_tag("form li.commit.button input#post_submit")
525
- end
526
- end
527
-
528
- end
529
-
530
- end