formtastic 4.0.0 → 5.0.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 (152) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +13 -13
  3. data/CHANGELOG.md +10 -1
  4. data/Gemfile.lock +99 -64
  5. data/README.md +7 -2
  6. data/formtastic.gemspec +5 -3
  7. data/gemfiles/{rails_5.2 → rails_7.0}/Gemfile +1 -1
  8. data/gemfiles/rails_7.1/Gemfile +5 -0
  9. data/gemfiles/rails_edge/Gemfile +1 -1
  10. data/lib/formtastic/action_class_finder.rb +1 -0
  11. data/lib/formtastic/actions/base.rb +1 -0
  12. data/lib/formtastic/actions/button_action.rb +1 -0
  13. data/lib/formtastic/actions/buttonish.rb +1 -0
  14. data/lib/formtastic/actions/input_action.rb +1 -0
  15. data/lib/formtastic/actions/link_action.rb +1 -0
  16. data/lib/formtastic/actions.rb +1 -0
  17. data/lib/formtastic/deprecation.rb +2 -1
  18. data/lib/formtastic/engine.rb +1 -0
  19. data/lib/formtastic/form_builder.rb +1 -0
  20. data/lib/formtastic/helpers/action_helper.rb +1 -0
  21. data/lib/formtastic/helpers/actions_helper.rb +1 -0
  22. data/lib/formtastic/helpers/enum.rb +1 -0
  23. data/lib/formtastic/helpers/errors_helper.rb +1 -0
  24. data/lib/formtastic/helpers/fieldset_wrapper.rb +1 -0
  25. data/lib/formtastic/helpers/file_column_detection.rb +1 -0
  26. data/lib/formtastic/helpers/form_helper.rb +1 -0
  27. data/lib/formtastic/helpers/input_helper.rb +2 -4
  28. data/lib/formtastic/helpers/inputs_helper.rb +2 -1
  29. data/lib/formtastic/helpers/reflection.rb +1 -0
  30. data/lib/formtastic/helpers.rb +1 -1
  31. data/lib/formtastic/html_attributes.rb +1 -0
  32. data/lib/formtastic/i18n.rb +1 -0
  33. data/lib/formtastic/input_class_finder.rb +1 -0
  34. data/lib/formtastic/inputs/base/associations.rb +1 -0
  35. data/lib/formtastic/inputs/base/choices.rb +2 -1
  36. data/lib/formtastic/inputs/base/collections.rb +4 -1
  37. data/lib/formtastic/inputs/base/database.rb +5 -7
  38. data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
  39. data/lib/formtastic/inputs/base/errors.rb +3 -2
  40. data/lib/formtastic/inputs/base/fileish.rb +1 -0
  41. data/lib/formtastic/inputs/base/hints.rb +1 -0
  42. data/lib/formtastic/inputs/base/html.rb +2 -1
  43. data/lib/formtastic/inputs/base/labelling.rb +3 -2
  44. data/lib/formtastic/inputs/base/naming.rb +1 -0
  45. data/lib/formtastic/inputs/base/numeric.rb +1 -0
  46. data/lib/formtastic/inputs/base/options.rb +1 -0
  47. data/lib/formtastic/inputs/base/placeholder.rb +1 -0
  48. data/lib/formtastic/inputs/base/stringish.rb +1 -0
  49. data/lib/formtastic/inputs/base/timeish.rb +4 -3
  50. data/lib/formtastic/inputs/base/validations.rb +2 -1
  51. data/lib/formtastic/inputs/base/wrapping.rb +1 -0
  52. data/lib/formtastic/inputs/base.rb +3 -2
  53. data/lib/formtastic/inputs/boolean_input.rb +2 -1
  54. data/lib/formtastic/inputs/check_boxes_input.rb +2 -1
  55. data/lib/formtastic/inputs/color_input.rb +1 -0
  56. data/lib/formtastic/inputs/country_input.rb +1 -0
  57. data/lib/formtastic/inputs/datalist_input.rb +1 -0
  58. data/lib/formtastic/inputs/date_picker_input.rb +1 -0
  59. data/lib/formtastic/inputs/date_select_input.rb +1 -0
  60. data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
  61. data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
  62. data/lib/formtastic/inputs/email_input.rb +1 -0
  63. data/lib/formtastic/inputs/file_input.rb +1 -0
  64. data/lib/formtastic/inputs/hidden_input.rb +3 -2
  65. data/lib/formtastic/inputs/number_input.rb +1 -0
  66. data/lib/formtastic/inputs/password_input.rb +1 -0
  67. data/lib/formtastic/inputs/phone_input.rb +1 -0
  68. data/lib/formtastic/inputs/radio_input.rb +1 -0
  69. data/lib/formtastic/inputs/range_input.rb +1 -0
  70. data/lib/formtastic/inputs/search_input.rb +1 -0
  71. data/lib/formtastic/inputs/select_input.rb +1 -0
  72. data/lib/formtastic/inputs/string_input.rb +1 -0
  73. data/lib/formtastic/inputs/text_input.rb +1 -0
  74. data/lib/formtastic/inputs/time_picker_input.rb +1 -0
  75. data/lib/formtastic/inputs/time_select_input.rb +1 -0
  76. data/lib/formtastic/inputs/time_zone_input.rb +1 -0
  77. data/lib/formtastic/inputs/url_input.rb +1 -0
  78. data/lib/formtastic/inputs.rb +1 -0
  79. data/lib/formtastic/localized_string.rb +1 -0
  80. data/lib/formtastic/localizer.rb +1 -0
  81. data/lib/formtastic/namespaced_class_finder.rb +7 -8
  82. data/lib/formtastic/version.rb +2 -1
  83. data/lib/formtastic.rb +1 -0
  84. data/lib/generators/formtastic/form/form_generator.rb +1 -0
  85. data/lib/generators/formtastic/input/input_generator.rb +1 -0
  86. data/lib/generators/formtastic/install/install_generator.rb +1 -0
  87. data/lib/generators/templates/formtastic.rb +1 -0
  88. data/script/integration-template.rb +2 -3
  89. data/spec/action_class_finder_spec.rb +1 -0
  90. data/spec/actions/button_action_spec.rb +17 -16
  91. data/spec/actions/generic_action_spec.rb +130 -129
  92. data/spec/actions/input_action_spec.rb +16 -15
  93. data/spec/actions/link_action_spec.rb +25 -24
  94. data/spec/builder/custom_builder_spec.rb +5 -4
  95. data/spec/builder/error_proc_spec.rb +2 -1
  96. data/spec/builder/semantic_fields_for_spec.rb +26 -25
  97. data/spec/fast_spec_helper.rb +1 -0
  98. data/spec/generators/formtastic/form/form_generator_spec.rb +8 -7
  99. data/spec/generators/formtastic/input/input_generator_spec.rb +1 -0
  100. data/spec/generators/formtastic/install/install_generator_spec.rb +1 -0
  101. data/spec/helpers/action_helper_spec.rb +15 -14
  102. data/spec/helpers/actions_helper_spec.rb +42 -41
  103. data/spec/helpers/form_helper_spec.rb +26 -19
  104. data/spec/helpers/input_helper_spec.rb +70 -69
  105. data/spec/helpers/inputs_helper_spec.rb +179 -179
  106. data/spec/helpers/reflection_helper_spec.rb +4 -3
  107. data/spec/helpers/semantic_errors_helper_spec.rb +4 -3
  108. data/spec/i18n_spec.rb +13 -12
  109. data/spec/input_class_finder_spec.rb +1 -0
  110. data/spec/inputs/base/collections_spec.rb +2 -0
  111. data/spec/inputs/base/validations_spec.rb +1 -0
  112. data/spec/inputs/boolean_input_spec.rb +66 -65
  113. data/spec/inputs/check_boxes_input_spec.rb +89 -88
  114. data/spec/inputs/color_input_spec.rb +7 -6
  115. data/spec/inputs/country_input_spec.rb +10 -9
  116. data/spec/inputs/custom_input_spec.rb +1 -0
  117. data/spec/inputs/datalist_input_spec.rb +2 -1
  118. data/spec/inputs/date_picker_input_spec.rb +109 -108
  119. data/spec/inputs/date_select_input_spec.rb +63 -62
  120. data/spec/inputs/datetime_picker_input_spec.rb +118 -117
  121. data/spec/inputs/datetime_select_input_spec.rb +72 -71
  122. data/spec/inputs/email_input_spec.rb +16 -15
  123. data/spec/inputs/file_input_spec.rb +17 -16
  124. data/spec/inputs/hidden_input_spec.rb +29 -28
  125. data/spec/inputs/include_blank_spec.rb +7 -6
  126. data/spec/inputs/label_spec.rb +25 -24
  127. data/spec/inputs/number_input_spec.rb +159 -158
  128. data/spec/inputs/password_input_spec.rb +16 -15
  129. data/spec/inputs/phone_input_spec.rb +16 -15
  130. data/spec/inputs/placeholder_spec.rb +17 -16
  131. data/spec/inputs/radio_input_spec.rb +58 -57
  132. data/spec/inputs/range_input_spec.rb +108 -107
  133. data/spec/inputs/readonly_spec.rb +5 -4
  134. data/spec/inputs/search_input_spec.rb +15 -14
  135. data/spec/inputs/select_input_spec.rb +144 -93
  136. data/spec/inputs/string_input_spec.rb +36 -35
  137. data/spec/inputs/text_input_spec.rb +32 -31
  138. data/spec/inputs/time_picker_input_spec.rb +110 -109
  139. data/spec/inputs/time_select_input_spec.rb +71 -70
  140. data/spec/inputs/time_zone_input_spec.rb +21 -20
  141. data/spec/inputs/url_input_spec.rb +16 -15
  142. data/spec/inputs/with_options_spec.rb +8 -7
  143. data/spec/localizer_spec.rb +1 -0
  144. data/spec/namespaced_class_finder_spec.rb +17 -5
  145. data/spec/schema.rb +1 -0
  146. data/spec/spec_helper.rb +8 -8
  147. data/spec/support/custom_macros.rb +64 -63
  148. data/spec/support/deprecation.rb +2 -1
  149. data/spec/support/shared_examples.rb +2 -1
  150. data/spec/support/specialized_class_finder_shared_example.rb +1 -0
  151. data/spec/support/test_environment.rb +1 -0
  152. metadata +29 -14
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe 'time_picker input' do
@@ -6,17 +7,17 @@ RSpec.describe 'time_picker input' do
6
7
  include FormtasticSpecHelper
7
8
 
8
9
  before do
9
- @output_buffer = ''
10
+ @output_buffer = ActionView::OutputBuffer.new ''
10
11
  mock_everything
11
12
  end
12
-
13
+
13
14
  context "with an object" do
14
15
  before do
15
16
  concat(semantic_form_for(@new_post) do |builder|
16
17
  concat(builder.input(:publish_at, :as => :time_picker))
17
18
  end)
18
19
  end
19
-
20
+
20
21
  it_should_have_input_wrapper_with_class(:time_picker)
21
22
  it_should_have_input_wrapper_with_class(:input)
22
23
  it_should_have_input_wrapper_with_class(:stringish)
@@ -29,36 +30,36 @@ RSpec.describe 'time_picker input' do
29
30
  it_should_apply_custom_input_attributes_when_input_html_provided(:date_picker)
30
31
  it_should_apply_custom_for_to_label_when_input_html_id_provided(:date_picker)
31
32
  # TODO why does this blow-up it_should_apply_error_logic_for_input_type(:date_picker)
32
-
33
+
33
34
  end
34
-
35
+
35
36
  describe "size attribute" do
36
-
37
+
37
38
  it "defaults to 5 chars (HH:MM)" do
38
39
  concat(
39
40
  semantic_form_for(@new_post) do |f|
40
41
  concat(f.input(:publish_at, :as => :time_picker))
41
42
  end
42
43
  )
43
- expect(output_buffer).to have_tag "input[size='5']"
44
+ expect(output_buffer.to_str).to have_tag "input[size='5']"
44
45
  end
45
-
46
+
46
47
  it "can be set from :input_html options" do
47
48
  concat(
48
49
  semantic_form_for(@new_post) do |f|
49
50
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :size => "11" }))
50
51
  end
51
52
  )
52
- expect(output_buffer).to have_tag "input[size='11']"
53
+ expect(output_buffer.to_str).to have_tag "input[size='11']"
53
54
  end
54
-
55
+
55
56
  it "can be set from options (ignoring input_html)" do
56
57
  concat(
57
58
  semantic_form_for(@new_post) do |f|
58
59
  concat(f.input(:publish_at, :as => :time_picker, :size => '12', :input_html => { :size => "11" }))
59
60
  end
60
61
  )
61
- expect(output_buffer).to have_tag "input[size='12']"
62
+ expect(output_buffer.to_str).to have_tag "input[size='12']"
62
63
  end
63
64
 
64
65
  end
@@ -71,7 +72,7 @@ RSpec.describe 'time_picker input' do
71
72
  concat(f.input(:publish_at, :as => :time_picker))
72
73
  end
73
74
  )
74
- expect(output_buffer).to have_tag "input[maxlength='5']"
75
+ expect(output_buffer.to_str).to have_tag "input[maxlength='5']"
75
76
  end
76
77
 
77
78
  it "can be set from :input_html options" do
@@ -80,58 +81,58 @@ RSpec.describe 'time_picker input' do
80
81
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :maxlength => "11" }))
81
82
  end
82
83
  )
83
- expect(output_buffer).to have_tag "input[maxlength='11']"
84
+ expect(output_buffer.to_str).to have_tag "input[maxlength='11']"
84
85
  end
85
-
86
+
86
87
  it "can be set from options (ignoring input_html)" do
87
88
  concat(
88
89
  semantic_form_for(@new_post) do |f|
89
90
  concat(f.input(:publish_at, :as => :time_picker, :maxlength => 12, :input_html => { :maxlength => "11" }))
90
91
  end
91
92
  )
92
- expect(output_buffer).to have_tag "input[maxlength='12']"
93
+ expect(output_buffer.to_str).to have_tag "input[maxlength='12']"
93
94
  end
94
-
95
+
95
96
  end
96
-
97
+
97
98
  describe "value attribute" do
98
-
99
+
99
100
  context "when method returns nil" do
100
-
101
+
101
102
  it "has no value" do
102
103
  concat(
103
104
  semantic_form_for(@new_post) do |f|
104
105
  concat(f.input(:publish_at, :as => :time_picker ))
105
106
  end
106
107
  )
107
- expect(output_buffer).not_to have_tag "li input[value]"
108
+ expect(output_buffer.to_str).not_to have_tag "li input[value]"
108
109
  end
109
-
110
+
110
111
  it "can be set from :input_html options" do
111
112
  concat(
112
113
  semantic_form_for(@new_post) do |f|
113
114
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:00" }))
114
115
  end
115
116
  )
116
- expect(output_buffer).to have_tag "input[value='12:00']"
117
+ expect(output_buffer.to_str).to have_tag "input[value='12:00']"
117
118
  end
118
-
119
+
119
120
  end
120
-
121
+
121
122
  context "when method returns a Date" do
122
-
123
+
123
124
  before do
124
125
  @date = Date.new(2000, 11, 11)
125
126
  allow(@new_post).to receive(:publish_at).and_return(@date)
126
127
  end
127
-
128
+
128
129
  it "renders 00:00" do
129
130
  concat(
130
131
  semantic_form_for(@new_post) do |f|
131
132
  concat(f.input(:publish_at, :as => :time_picker ))
132
133
  end
133
134
  )
134
- expect(output_buffer).to have_tag "input[value='00:00']"
135
+ expect(output_buffer.to_str).to have_tag "input[value='00:00']"
135
136
  end
136
137
 
137
138
  it "can be set from :input_html options" do
@@ -140,114 +141,114 @@ RSpec.describe 'time_picker input' do
140
141
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "23:59" }))
141
142
  end
142
143
  )
143
- expect(output_buffer).to have_tag "input[value='23:59']"
144
+ expect(output_buffer.to_str).to have_tag "input[value='23:59']"
144
145
  end
145
-
146
+
146
147
  end
147
-
148
+
148
149
  context "when method returns a Time" do
149
-
150
+
150
151
  before do
151
152
  @time = Time.utc(2000,11,11,11,11,11)
152
153
  allow(@new_post).to receive(:publish_at).and_return(@time)
153
154
  end
154
-
155
+
155
156
  it "renders the time as a HH:MM" do
156
157
  concat(
157
158
  semantic_form_for(@new_post) do |f|
158
159
  concat(f.input(:publish_at, :as => :time_picker ))
159
160
  end
160
161
  )
161
- expect(output_buffer).to have_tag "input[value='11:11']"
162
+ expect(output_buffer.to_str).to have_tag "input[value='11:11']"
162
163
  end
163
-
164
+
164
165
  it "can be set from :input_html options" do
165
166
  concat(
166
167
  semantic_form_for(@new_post) do |f|
167
168
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:12" }))
168
169
  end
169
170
  )
170
- expect(output_buffer).to have_tag "input[value='12:12']"
171
+ expect(output_buffer.to_str).to have_tag "input[value='12:12']"
171
172
  end
172
-
173
+
173
174
  end
174
-
175
+
175
176
  context "when method returns an empty String" do
176
-
177
+
177
178
  before do
178
179
  allow(@new_post).to receive(:publish_at).and_return("")
179
180
  end
180
-
181
+
181
182
  it "will be empty" do
182
183
  concat(
183
184
  semantic_form_for(@new_post) do |f|
184
185
  concat(f.input(:publish_at, :as => :time_picker ))
185
186
  end
186
187
  )
187
- expect(output_buffer).to have_tag "input[value='']"
188
+ expect(output_buffer.to_str).to have_tag "input[value='']"
188
189
  end
189
-
190
+
190
191
  it "can be set from :input_html options" do
191
192
  concat(
192
193
  semantic_form_for(@new_post) do |f|
193
194
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:12:12" }))
194
195
  end
195
196
  )
196
- expect(output_buffer).to have_tag "input[value='12:12:12']"
197
+ expect(output_buffer.to_str).to have_tag "input[value='12:12:12']"
197
198
  end
198
-
199
+
199
200
  end
200
-
201
+
201
202
  context "when method returns a String" do
202
-
203
+
203
204
  before do
204
205
  allow(@new_post).to receive(:publish_at).and_return("yeah")
205
206
  end
206
-
207
+
207
208
  it "will be the string" do
208
209
  concat(
209
210
  semantic_form_for(@new_post) do |f|
210
211
  concat(f.input(:publish_at, :as => :time_picker ))
211
212
  end
212
213
  )
213
- expect(output_buffer).to have_tag "input[value='yeah']"
214
+ expect(output_buffer.to_str).to have_tag "input[value='yeah']"
214
215
  end
215
-
216
+
216
217
  it "can be set from :input_html options" do
217
218
  concat(
218
219
  semantic_form_for(@new_post) do |f|
219
220
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:12:12" }))
220
221
  end
221
222
  )
222
- expect(output_buffer).to have_tag "input[value='12:12:12']"
223
+ expect(output_buffer.to_str).to have_tag "input[value='12:12:12']"
223
224
  end
224
-
225
+
225
226
  end
226
227
 
227
228
  end
228
-
229
+
229
230
  describe "min attribute" do
230
-
231
+
231
232
  it "will be omitted by default" do
232
233
  concat(
233
234
  semantic_form_for(@new_post) do |f|
234
235
  concat(f.input(:publish_at, :as => :time_picker))
235
236
  end
236
237
  )
237
- expect(output_buffer).not_to have_tag "input[min]"
238
+ expect(output_buffer.to_str).not_to have_tag "input[min]"
238
239
  end
239
-
240
+
240
241
  it "can be set from :input_html options" do
241
242
  concat(
242
243
  semantic_form_for(@new_post) do |f|
243
244
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :min => "13:00" }))
244
245
  end
245
246
  )
246
- expect(output_buffer).to have_tag "input[min='13:00']"
247
+ expect(output_buffer.to_str).to have_tag "input[min='13:00']"
247
248
  end
248
-
249
+
249
250
  end
250
-
251
+
251
252
  describe "max attribute" do
252
253
 
253
254
  it "will be omitted by default" do
@@ -256,29 +257,29 @@ RSpec.describe 'time_picker input' do
256
257
  concat(f.input(:publish_at, :as => :time_picker))
257
258
  end
258
259
  )
259
- expect(output_buffer).not_to have_tag "input[max]"
260
+ expect(output_buffer.to_str).not_to have_tag "input[max]"
260
261
  end
261
-
262
+
262
263
  it "can be set from :input_html options" do
263
264
  concat(
264
265
  semantic_form_for(@new_post) do |f|
265
266
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :max => "13:00" }))
266
267
  end
267
268
  )
268
- expect(output_buffer).to have_tag "input[max='13:00']"
269
+ expect(output_buffer.to_str).to have_tag "input[max='13:00']"
269
270
  end
270
-
271
+
271
272
  end
272
-
273
+
273
274
  describe "step attribute" do
274
-
275
+
275
276
  it "defaults to 60 (seconds)" do
276
277
  concat(
277
278
  semantic_form_for(@new_post) do |f|
278
279
  concat(f.input(:publish_at, :as => :time_picker))
279
280
  end
280
281
  )
281
- expect(output_buffer).to have_tag "input[step='60']"
282
+ expect(output_buffer.to_str).to have_tag "input[step='60']"
282
283
  end
283
284
 
284
285
  it "can be set from :input_html options" do
@@ -287,124 +288,124 @@ RSpec.describe 'time_picker input' do
287
288
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :step => "3600" }))
288
289
  end
289
290
  )
290
- expect(output_buffer).to have_tag "input[step='3600']"
291
+ expect(output_buffer.to_str).to have_tag "input[step='3600']"
291
292
  end
292
-
293
+
293
294
  describe "macros" do
294
- before do
295
+ before do
295
296
  concat(
296
297
  semantic_form_for(@new_post) do |f|
297
298
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :step => step }))
298
299
  end
299
300
  )
300
301
  end
301
-
302
+
302
303
  context ":second" do
303
304
  let(:step) { :second }
304
305
  it "uses 1" do
305
- expect(output_buffer).to have_tag "input[step='1']"
306
+ expect(output_buffer.to_str).to have_tag "input[step='1']"
306
307
  end
307
308
  end
308
-
309
+
309
310
  context ":minute" do
310
311
  let(:step) { :minute }
311
312
  it "uses 60" do
312
- expect(output_buffer).to have_tag "input[step='60']"
313
+ expect(output_buffer.to_str).to have_tag "input[step='60']"
313
314
  end
314
315
  end
315
-
316
+
316
317
  context ":fifteen_minutes" do
317
318
  let(:step) { :fifteen_minutes }
318
319
  it "uses 900" do
319
- expect(output_buffer).to have_tag "input[step='900']"
320
+ expect(output_buffer.to_str).to have_tag "input[step='900']"
320
321
  end
321
322
  end
322
-
323
+
323
324
  context ":quarter_hour" do
324
325
  let(:step) { :quarter_hour }
325
326
  it "uses 900" do
326
- expect(output_buffer).to have_tag "input[step='900']"
327
+ expect(output_buffer.to_str).to have_tag "input[step='900']"
327
328
  end
328
329
  end
329
-
330
+
330
331
  context ":thirty_minutes" do
331
332
  let(:step) { :thirty_minutes }
332
333
  it "uses 1800" do
333
- expect(output_buffer).to have_tag "input[step='1800']"
334
+ expect(output_buffer.to_str).to have_tag "input[step='1800']"
334
335
  end
335
336
  end
336
-
337
+
337
338
  context ":half_hour" do
338
339
  let(:step) { :half_hour }
339
340
  it "uses 1800" do
340
- expect(output_buffer).to have_tag "input[step='1800']"
341
+ expect(output_buffer.to_str).to have_tag "input[step='1800']"
341
342
  end
342
343
  end
343
-
344
+
344
345
  context ":hour" do
345
346
  let(:step) { :hour }
346
347
  it "uses 3600" do
347
- expect(output_buffer).to have_tag "input[step='3600']"
348
+ expect(output_buffer.to_str).to have_tag "input[step='3600']"
348
349
  end
349
350
  end
350
-
351
+
351
352
  context ":sixty_minutes" do
352
353
  let(:step) { :sixty_minutes }
353
354
  it "uses 3600" do
354
- expect(output_buffer).to have_tag "input[step='3600']"
355
+ expect(output_buffer.to_str).to have_tag "input[step='3600']"
355
356
  end
356
357
  end
357
-
358
+
358
359
  end
359
-
360
+
360
361
  end
361
-
362
+
362
363
  describe "placeholder attribute" do
363
-
364
+
364
365
  it "will be omitted" do
365
366
  concat(
366
367
  semantic_form_for(@new_post) do |f|
367
368
  concat(f.input(:publish_at, :as => :time_picker))
368
369
  end
369
370
  )
370
- expect(output_buffer).not_to have_tag "input[placeholder]"
371
+ expect(output_buffer.to_str).not_to have_tag "input[placeholder]"
371
372
  end
372
-
373
+
373
374
  it "can be set from :input_html options" do
374
375
  concat(
375
376
  semantic_form_for(@new_post) do |f|
376
377
  concat(f.input(:publish_at, :as => :time_picker, :input_html => { :placeholder => "HH:MM" }))
377
378
  end
378
379
  )
379
- expect(output_buffer).to have_tag "input[placeholder='HH:MM']"
380
+ expect(output_buffer.to_str).to have_tag "input[placeholder='HH:MM']"
380
381
  end
381
-
382
+
382
383
  context "with i18n set" do
383
384
  before do
384
385
  ::I18n.backend.store_translations :en, :formtastic => { :placeholders => { :publish_at => 'HH:MM' }}
385
386
  end
386
-
387
+
387
388
  it "can be set with i18n" do
388
389
  with_config :i18n_lookups_by_default, true do
389
390
  concat(semantic_form_for(@new_post) do |builder|
390
391
  concat(builder.input(:publish_at, :as => :time_picker))
391
392
  end)
392
- expect(output_buffer).to have_tag('input[@placeholder="HH:MM"]')
393
+ expect(output_buffer.to_str).to have_tag('input[@placeholder="HH:MM"]')
393
394
  end
394
395
  end
395
-
396
+
396
397
  it "can be set with input_html, trumping i18n" do
397
398
  with_config :i18n_lookups_by_default, true do
398
399
  concat(semantic_form_for(@new_post) do |builder|
399
400
  concat(builder.input(:publish_at, :as => :time_picker, :input_html => { :placeholder => "Something" }))
400
401
  end)
401
- expect(output_buffer).to have_tag('input[@placeholder="Something"]')
402
+ expect(output_buffer.to_str).to have_tag('input[@placeholder="Something"]')
402
403
  end
403
404
  end
404
405
  end
405
-
406
+
406
407
  end
407
-
408
+
408
409
  describe "when namespace is provided" do
409
410
  before do
410
411
  concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
@@ -415,10 +416,10 @@ RSpec.describe 'time_picker input' do
415
416
  it_should_have_input_wrapper_with_id("context2_post_publish_at_input")
416
417
  it_should_have_label_and_input_with_id("context2_post_publish_at")
417
418
  end
418
-
419
+
419
420
  describe "when index is provided" do
420
421
  before do
421
- @output_buffer = ''
422
+ @output_buffer = ActionView::OutputBuffer.new ''
422
423
  mock_everything
423
424
 
424
425
  concat(semantic_form_for(@new_post) do |builder|
@@ -427,29 +428,29 @@ RSpec.describe 'time_picker input' do
427
428
  end)
428
429
  end)
429
430
  end
430
-
431
+
431
432
  it 'should index the id of the wrapper' do
432
- expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
433
+ expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_created_at_input")
433
434
  end
434
-
435
+
435
436
  it 'should index the id of the select tag' do
436
- expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at")
437
+ expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_created_at")
437
438
  end
438
-
439
+
439
440
  it 'should index the name of the select tag' do
440
- expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at]']")
441
+ expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][created_at]']")
441
442
  end
442
443
  end
443
-
444
+
444
445
  describe "when required" do
445
446
  it "should add the required attribute to the input's html options" do
446
- with_config :use_required_attribute, true do
447
+ with_config :use_required_attribute, true do
447
448
  concat(semantic_form_for(@new_post) do |builder|
448
449
  concat(builder.input(:publish_at, :as => :time_picker, :required => true))
449
450
  end)
450
- expect(output_buffer).to have_tag("input[@required]")
451
+ expect(output_buffer.to_str).to have_tag("input[@required]")
451
452
  end
452
453
  end
453
454
  end
454
-
455
+
455
456
  end