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 'date_picker input' do
@@ -6,17 +7,17 @@ RSpec.describe 'date_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 => :date_picker))
17
18
  end)
18
19
  end
19
-
20
+
20
21
  it_should_have_input_wrapper_with_class(:date_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 'date_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 10 chars (YYYY-YY-YY)" do
38
39
  concat(
39
40
  semantic_form_for(@new_post) do |f|
40
41
  concat(f.input(:publish_at, :as => :date_picker))
41
42
  end
42
43
  )
43
- expect(output_buffer).to have_tag "input[size='10']"
44
+ expect(output_buffer.to_str).to have_tag "input[size='10']"
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 => :date_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 => :date_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 'date_picker input' do
71
72
  concat(f.input(:publish_at, :as => :date_picker))
72
73
  end
73
74
  )
74
- expect(output_buffer).to have_tag "input[maxlength='10']"
75
+ expect(output_buffer.to_str).to have_tag "input[maxlength='10']"
75
76
  end
76
77
 
77
78
  it "can be set from :input_html options" do
@@ -80,58 +81,58 @@ RSpec.describe 'date_picker input' do
80
81
  concat(f.input(:publish_at, :as => :date_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 => :date_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 => :date_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 => :date_picker, :input_html => { :value => "1111-11-11" }))
114
115
  end
115
116
  )
116
- expect(output_buffer).to have_tag "input[value='1111-11-11']"
117
+ expect(output_buffer.to_str).to have_tag "input[value='1111-11-11']"
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 the date as YYYY-MM-DD" do
129
130
  concat(
130
131
  semantic_form_for(@new_post) do |f|
131
132
  concat(f.input(:publish_at, :as => :date_picker ))
132
133
  end
133
134
  )
134
- expect(output_buffer).to have_tag "input[value='#{@date.to_s}']"
135
+ expect(output_buffer.to_str).to have_tag "input[value='#{@date.to_s}']"
135
136
  end
136
137
 
137
138
  it "can be set from :input_html options" do
@@ -140,114 +141,114 @@ RSpec.describe 'date_picker input' do
140
141
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
141
142
  end
142
143
  )
143
- expect(output_buffer).to have_tag "input[value='1111-11-11']"
144
+ expect(output_buffer.to_str).to have_tag "input[value='1111-11-11']"
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 YYYY-MM-DD" do
156
157
  concat(
157
158
  semantic_form_for(@new_post) do |f|
158
159
  concat(f.input(:publish_at, :as => :date_picker ))
159
160
  end
160
161
  )
161
- expect(output_buffer).to have_tag "input[value='2000-11-11']"
162
+ expect(output_buffer.to_str).to have_tag "input[value='2000-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 => :date_picker, :input_html => { :value => "1111-11-11" }))
168
169
  end
169
170
  )
170
- expect(output_buffer).to have_tag "input[value='1111-11-11']"
171
+ expect(output_buffer.to_str).to have_tag "input[value='1111-11-11']"
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 => :date_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 => :date_picker, :input_html => { :value => "1111-11-11" }))
194
195
  end
195
196
  )
196
- expect(output_buffer).to have_tag "input[value='1111-11-11']"
197
+ expect(output_buffer.to_str).to have_tag "input[value='1111-11-11']"
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 => :date_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 => :date_picker, :input_html => { :value => "1111-11-11" }))
220
221
  end
221
222
  )
222
- expect(output_buffer).to have_tag "input[value='1111-11-11']"
223
+ expect(output_buffer.to_str).to have_tag "input[value='1111-11-11']"
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 => :date_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 => :date_picker, :input_html => { :min => "1970-01-01" }))
244
245
  end
245
246
  )
246
- expect(output_buffer).to have_tag "input[min='1970-01-01']"
247
+ expect(output_buffer.to_str).to have_tag "input[min='1970-01-01']"
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 'date_picker input' do
256
257
  concat(f.input(:publish_at, :as => :date_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 => :date_picker, :input_html => { :max => "1970-01-01" }))
266
267
  end
267
268
  )
268
- expect(output_buffer).to have_tag "input[max='1970-01-01']"
269
+ expect(output_buffer.to_str).to have_tag "input[max='1970-01-01']"
269
270
  end
270
-
271
+
271
272
  end
272
-
273
+
273
274
  describe "step attribute" do
274
-
275
+
275
276
  it "defaults to 1" do
276
277
  concat(
277
278
  semantic_form_for(@new_post) do |f|
278
279
  concat(f.input(:publish_at, :as => :date_picker))
279
280
  end
280
281
  )
281
- expect(output_buffer).to have_tag "input[step='1']"
282
+ expect(output_buffer.to_str).to have_tag "input[step='1']"
282
283
  end
283
284
 
284
285
  it "can be set from :input_html options" do
@@ -287,118 +288,118 @@ RSpec.describe 'date_picker input' do
287
288
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :step => "5" }))
288
289
  end
289
290
  )
290
- expect(output_buffer).to have_tag "input[step='5']"
291
+ expect(output_buffer.to_str).to have_tag "input[step='5']"
291
292
  end
292
-
293
+
293
294
  describe "macros" do
294
-
295
- before do
295
+
296
+ before do
296
297
  concat(
297
298
  semantic_form_for(@new_post) do |f|
298
299
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :step => step }))
299
300
  end
300
301
  )
301
302
  end
302
-
303
+
303
304
  context ":day" do
304
305
  let(:step) { :day }
305
306
  it "uses 1" do
306
- expect(output_buffer).to have_tag "input[step='1']"
307
+ expect(output_buffer.to_str).to have_tag "input[step='1']"
307
308
  end
308
309
  end
309
-
310
+
310
311
  context ":seven_days" do
311
312
  let(:step) { :seven_days }
312
313
  it "uses 7" do
313
- expect(output_buffer).to have_tag "input[step='7']"
314
+ expect(output_buffer.to_str).to have_tag "input[step='7']"
314
315
  end
315
316
  end
316
-
317
+
317
318
  context ":week" do
318
319
  let(:step) { :week }
319
320
  it "uses 7" do
320
- expect(output_buffer).to have_tag "input[step='7']"
321
+ expect(output_buffer.to_str).to have_tag "input[step='7']"
321
322
  end
322
323
  end
323
-
324
+
324
325
  context ":fortnight" do
325
326
  let(:step) { :fortnight }
326
327
  it "uses 14" do
327
- expect(output_buffer).to have_tag "input[step='14']"
328
+ expect(output_buffer.to_str).to have_tag "input[step='14']"
328
329
  end
329
330
  end
330
-
331
+
331
332
  context ":two_weeks" do
332
333
  let(:step) { :two_weeks }
333
334
  it "uses 14" do
334
- expect(output_buffer).to have_tag "input[step='14']"
335
+ expect(output_buffer.to_str).to have_tag "input[step='14']"
335
336
  end
336
337
  end
337
-
338
+
338
339
  context ":four_weeks" do
339
340
  let(:step) { :four_weeks }
340
341
  it "uses 28" do
341
- expect(output_buffer).to have_tag "input[step='28']"
342
+ expect(output_buffer.to_str).to have_tag "input[step='28']"
342
343
  end
343
344
  end
344
-
345
+
345
346
  context ":thirty_days" do
346
347
  let(:step) { :thirty_days }
347
348
  it "uses 30" do
348
- expect(output_buffer).to have_tag "input[step='30']"
349
+ expect(output_buffer.to_str).to have_tag "input[step='30']"
349
350
  end
350
351
  end
351
-
352
+
352
353
  end
353
-
354
+
354
355
  end
355
-
356
+
356
357
  describe "placeholder attribute" do
357
-
358
+
358
359
  it "will be omitted" do
359
360
  concat(
360
361
  semantic_form_for(@new_post) do |f|
361
362
  concat(f.input(:publish_at, :as => :date_picker))
362
363
  end
363
364
  )
364
- expect(output_buffer).not_to have_tag "input[placeholder]"
365
+ expect(output_buffer.to_str).not_to have_tag "input[placeholder]"
365
366
  end
366
-
367
+
367
368
  it "can be set from :input_html options" do
368
369
  concat(
369
370
  semantic_form_for(@new_post) do |f|
370
371
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :placeholder => "1970-01-01" }))
371
372
  end
372
373
  )
373
- expect(output_buffer).to have_tag "input[placeholder='1970-01-01']"
374
+ expect(output_buffer.to_str).to have_tag "input[placeholder='1970-01-01']"
374
375
  end
375
-
376
+
376
377
  context "with i18n set" do
377
378
  before do
378
379
  ::I18n.backend.store_translations :en, :formtastic => { :placeholders => { :publish_at => 'YYYY-MM-DD' }}
379
380
  end
380
-
381
+
381
382
  it "can be set with i18n" do
382
383
  with_config :i18n_lookups_by_default, true do
383
384
  concat(semantic_form_for(@new_post) do |builder|
384
385
  concat(builder.input(:publish_at, :as => :date_picker))
385
386
  end)
386
- expect(output_buffer).to have_tag('input[@placeholder="YYYY-MM-DD"]')
387
+ expect(output_buffer.to_str).to have_tag('input[@placeholder="YYYY-MM-DD"]')
387
388
  end
388
389
  end
389
-
390
+
390
391
  it "can be set with input_html, trumping i18n" do
391
392
  with_config :i18n_lookups_by_default, true do
392
393
  concat(semantic_form_for(@new_post) do |builder|
393
394
  concat(builder.input(:publish_at, :as => :date_picker, :input_html => { :placeholder => "Something" }))
394
395
  end)
395
- expect(output_buffer).to have_tag('input[@placeholder="Something"]')
396
+ expect(output_buffer.to_str).to have_tag('input[@placeholder="Something"]')
396
397
  end
397
398
  end
398
399
  end
399
-
400
+
400
401
  end
401
-
402
+
402
403
  describe "when namespace is provided" do
403
404
  before do
404
405
  concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
@@ -409,10 +410,10 @@ RSpec.describe 'date_picker input' do
409
410
  it_should_have_input_wrapper_with_id("context2_post_publish_at_input")
410
411
  it_should_have_label_and_input_with_id("context2_post_publish_at")
411
412
  end
412
-
413
+
413
414
  describe "when index is provided" do
414
415
  before do
415
- @output_buffer = ''
416
+ @output_buffer = ActionView::OutputBuffer.new ''
416
417
  mock_everything
417
418
 
418
419
  concat(semantic_form_for(@new_post) do |builder|
@@ -421,29 +422,29 @@ RSpec.describe 'date_picker input' do
421
422
  end)
422
423
  end)
423
424
  end
424
-
425
+
425
426
  it 'should index the id of the wrapper' do
426
- expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
427
+ expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_created_at_input")
427
428
  end
428
-
429
+
429
430
  it 'should index the id of the select tag' do
430
- expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at")
431
+ expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_created_at")
431
432
  end
432
-
433
+
433
434
  it 'should index the name of the select tag' do
434
- expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at]']")
435
+ expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][created_at]']")
435
436
  end
436
437
  end
437
-
438
+
438
439
  describe "when required" do
439
440
  it "should add the required attribute to the input's html options" do
440
- with_config :use_required_attribute, true do
441
+ with_config :use_required_attribute, true do
441
442
  concat(semantic_form_for(@new_post) do |builder|
442
443
  concat(builder.input(:publish_at, :as => :date_picker, :required => true))
443
444
  end)
444
- expect(output_buffer).to have_tag("input[@required]")
445
+ expect(output_buffer.to_str).to have_tag("input[@required]")
445
446
  end
446
447
  end
447
448
  end
448
-
449
+
449
450
  end