formtastic 3.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 (175) hide show
  1. checksums.yaml +5 -13
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/test.yml +61 -0
  4. data/.gitignore +3 -2
  5. data/CHANGELOG.md +61 -0
  6. data/Gemfile.lock +140 -0
  7. data/MIT-LICENSE +1 -1
  8. data/{README.textile → README.md} +191 -168
  9. data/RELEASE_PROCESS +3 -1
  10. data/Rakefile +24 -8
  11. data/app/assets/stylesheets/formtastic.css +1 -1
  12. data/bin/appraisal +8 -0
  13. data/formtastic.gemspec +13 -17
  14. data/gemfiles/rails_6.0/Gemfile +5 -0
  15. data/gemfiles/rails_6.1/Gemfile +5 -0
  16. data/gemfiles/rails_7.0/Gemfile +5 -0
  17. data/gemfiles/rails_7.1/Gemfile +5 -0
  18. data/gemfiles/rails_edge/Gemfile +13 -0
  19. data/lib/formtastic/action_class_finder.rb +19 -0
  20. data/lib/formtastic/actions/base.rb +1 -0
  21. data/lib/formtastic/actions/button_action.rb +56 -53
  22. data/lib/formtastic/actions/buttonish.rb +1 -0
  23. data/lib/formtastic/actions/input_action.rb +60 -57
  24. data/lib/formtastic/actions/link_action.rb +69 -67
  25. data/lib/formtastic/actions.rb +7 -3
  26. data/lib/formtastic/deprecation.rb +6 -0
  27. data/lib/formtastic/engine.rb +4 -1
  28. data/lib/formtastic/form_builder.rb +32 -25
  29. data/lib/formtastic/helpers/action_helper.rb +22 -31
  30. data/lib/formtastic/helpers/actions_helper.rb +1 -0
  31. data/lib/formtastic/helpers/enum.rb +14 -0
  32. data/lib/formtastic/helpers/errors_helper.rb +3 -2
  33. data/lib/formtastic/helpers/fieldset_wrapper.rb +16 -11
  34. data/lib/formtastic/helpers/file_column_detection.rb +1 -0
  35. data/lib/formtastic/helpers/form_helper.rb +4 -3
  36. data/lib/formtastic/helpers/input_helper.rb +59 -80
  37. data/lib/formtastic/helpers/inputs_helper.rb +33 -27
  38. data/lib/formtastic/helpers/reflection.rb +5 -4
  39. data/lib/formtastic/helpers.rb +2 -2
  40. data/lib/formtastic/html_attributes.rb +13 -1
  41. data/lib/formtastic/i18n.rb +2 -1
  42. data/lib/formtastic/input_class_finder.rb +19 -0
  43. data/lib/formtastic/inputs/base/associations.rb +1 -0
  44. data/lib/formtastic/inputs/base/choices.rb +4 -3
  45. data/lib/formtastic/inputs/base/collections.rb +47 -11
  46. data/lib/formtastic/inputs/base/database.rb +8 -5
  47. data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
  48. data/lib/formtastic/inputs/base/errors.rb +7 -6
  49. data/lib/formtastic/inputs/base/fileish.rb +1 -0
  50. data/lib/formtastic/inputs/base/hints.rb +2 -1
  51. data/lib/formtastic/inputs/base/html.rb +12 -10
  52. data/lib/formtastic/inputs/base/labelling.rb +3 -2
  53. data/lib/formtastic/inputs/base/naming.rb +5 -4
  54. data/lib/formtastic/inputs/base/numeric.rb +1 -0
  55. data/lib/formtastic/inputs/base/options.rb +3 -3
  56. data/lib/formtastic/inputs/base/placeholder.rb +1 -0
  57. data/lib/formtastic/inputs/base/stringish.rb +1 -0
  58. data/lib/formtastic/inputs/base/timeish.rb +9 -4
  59. data/lib/formtastic/inputs/base/validations.rb +39 -12
  60. data/lib/formtastic/inputs/base/wrapping.rb +2 -3
  61. data/lib/formtastic/inputs/base.rb +17 -12
  62. data/lib/formtastic/inputs/boolean_input.rb +2 -1
  63. data/lib/formtastic/inputs/check_boxes_input.rb +16 -24
  64. data/lib/formtastic/inputs/color_input.rb +1 -1
  65. data/lib/formtastic/inputs/country_input.rb +4 -1
  66. data/lib/formtastic/inputs/datalist_input.rb +42 -0
  67. data/lib/formtastic/inputs/date_picker_input.rb +1 -0
  68. data/lib/formtastic/inputs/date_select_input.rb +1 -0
  69. data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
  70. data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
  71. data/lib/formtastic/inputs/email_input.rb +1 -0
  72. data/lib/formtastic/inputs/file_input.rb +3 -2
  73. data/lib/formtastic/inputs/hidden_input.rb +3 -2
  74. data/lib/formtastic/inputs/number_input.rb +1 -0
  75. data/lib/formtastic/inputs/password_input.rb +1 -0
  76. data/lib/formtastic/inputs/phone_input.rb +1 -0
  77. data/lib/formtastic/inputs/radio_input.rb +26 -21
  78. data/lib/formtastic/inputs/range_input.rb +1 -0
  79. data/lib/formtastic/inputs/search_input.rb +1 -0
  80. data/lib/formtastic/inputs/select_input.rb +32 -10
  81. data/lib/formtastic/inputs/string_input.rb +1 -0
  82. data/lib/formtastic/inputs/text_input.rb +1 -0
  83. data/lib/formtastic/inputs/time_picker_input.rb +1 -0
  84. data/lib/formtastic/inputs/time_select_input.rb +1 -0
  85. data/lib/formtastic/inputs/time_zone_input.rb +17 -6
  86. data/lib/formtastic/inputs/url_input.rb +1 -0
  87. data/lib/formtastic/inputs.rb +33 -28
  88. data/lib/formtastic/localized_string.rb +2 -1
  89. data/lib/formtastic/localizer.rb +23 -24
  90. data/lib/formtastic/namespaced_class_finder.rb +98 -0
  91. data/lib/formtastic/version.rb +2 -1
  92. data/lib/formtastic.rb +19 -14
  93. data/lib/generators/formtastic/form/form_generator.rb +8 -2
  94. data/lib/generators/formtastic/input/input_generator.rb +47 -0
  95. data/lib/generators/formtastic/install/install_generator.rb +2 -0
  96. data/lib/generators/templates/formtastic.rb +29 -7
  97. data/lib/generators/templates/input.rb +19 -0
  98. data/sample/basic_inputs.html +1 -1
  99. data/script/integration-template.rb +73 -0
  100. data/script/integration.sh +19 -0
  101. data/spec/action_class_finder_spec.rb +13 -0
  102. data/spec/actions/button_action_spec.rb +21 -20
  103. data/spec/actions/generic_action_spec.rb +134 -133
  104. data/spec/actions/input_action_spec.rb +20 -19
  105. data/spec/actions/link_action_spec.rb +30 -29
  106. data/spec/builder/custom_builder_spec.rb +39 -22
  107. data/spec/builder/error_proc_spec.rb +6 -5
  108. data/spec/builder/semantic_fields_for_spec.rb +46 -45
  109. data/spec/fast_spec_helper.rb +13 -0
  110. data/spec/generators/formtastic/form/form_generator_spec.rb +33 -32
  111. data/spec/generators/formtastic/input/input_generator_spec.rb +125 -0
  112. data/spec/generators/formtastic/install/install_generator_spec.rb +10 -9
  113. data/spec/helpers/action_helper_spec.rb +70 -97
  114. data/spec/helpers/actions_helper_spec.rb +43 -42
  115. data/spec/helpers/form_helper_spec.rb +56 -39
  116. data/spec/helpers/input_helper_spec.rb +314 -255
  117. data/spec/helpers/inputs_helper_spec.rb +217 -202
  118. data/spec/helpers/reflection_helper_spec.rb +7 -6
  119. data/spec/helpers/semantic_errors_helper_spec.rb +26 -25
  120. data/spec/i18n_spec.rb +30 -29
  121. data/spec/input_class_finder_spec.rb +11 -0
  122. data/spec/inputs/base/collections_spec.rb +78 -0
  123. data/spec/inputs/base/validations_spec.rb +481 -0
  124. data/spec/inputs/boolean_input_spec.rb +73 -72
  125. data/spec/inputs/check_boxes_input_spec.rb +174 -123
  126. data/spec/inputs/color_input_spec.rb +53 -64
  127. data/spec/inputs/country_input_spec.rb +23 -22
  128. data/spec/inputs/custom_input_spec.rb +3 -6
  129. data/spec/inputs/datalist_input_spec.rb +62 -0
  130. data/spec/inputs/date_picker_input_spec.rb +114 -113
  131. data/spec/inputs/date_select_input_spec.rb +76 -61
  132. data/spec/inputs/datetime_picker_input_spec.rb +123 -122
  133. data/spec/inputs/datetime_select_input_spec.rb +85 -68
  134. data/spec/inputs/email_input_spec.rb +17 -16
  135. data/spec/inputs/file_input_spec.rb +18 -17
  136. data/spec/inputs/hidden_input_spec.rb +32 -31
  137. data/spec/inputs/include_blank_spec.rb +10 -9
  138. data/spec/inputs/label_spec.rb +36 -31
  139. data/spec/inputs/number_input_spec.rb +212 -211
  140. data/spec/inputs/password_input_spec.rb +17 -16
  141. data/spec/inputs/phone_input_spec.rb +17 -16
  142. data/spec/inputs/placeholder_spec.rb +18 -17
  143. data/spec/inputs/radio_input_spec.rb +92 -65
  144. data/spec/inputs/range_input_spec.rb +136 -135
  145. data/spec/inputs/readonly_spec.rb +51 -0
  146. data/spec/inputs/search_input_spec.rb +16 -15
  147. data/spec/inputs/select_input_spec.rb +209 -102
  148. data/spec/inputs/string_input_spec.rb +51 -50
  149. data/spec/inputs/text_input_spec.rb +34 -33
  150. data/spec/inputs/time_picker_input_spec.rb +115 -114
  151. data/spec/inputs/time_select_input_spec.rb +84 -70
  152. data/spec/inputs/time_zone_input_spec.rb +58 -31
  153. data/spec/inputs/url_input_spec.rb +17 -16
  154. data/spec/inputs/with_options_spec.rb +9 -8
  155. data/spec/localizer_spec.rb +18 -17
  156. data/spec/namespaced_class_finder_spec.rb +91 -0
  157. data/spec/schema.rb +22 -0
  158. data/spec/spec_helper.rb +180 -249
  159. data/spec/support/custom_macros.rb +128 -98
  160. data/spec/support/deprecation.rb +2 -1
  161. data/spec/support/shared_examples.rb +13 -0
  162. data/spec/support/specialized_class_finder_shared_example.rb +28 -0
  163. data/spec/support/test_environment.rb +25 -10
  164. metadata +95 -136
  165. data/.travis.yml +0 -28
  166. data/Appraisals +0 -25
  167. data/CHANGELOG +0 -27
  168. data/gemfiles/rails_3.2.gemfile +0 -7
  169. data/gemfiles/rails_4.0.4.gemfile +0 -7
  170. data/gemfiles/rails_4.1.gemfile +0 -7
  171. data/gemfiles/rails_4.gemfile +0 -7
  172. data/gemfiles/rails_edge.gemfile +0 -10
  173. data/lib/formtastic/util.rb +0 -53
  174. data/spec/support/deferred_garbage_collection.rb +0 -21
  175. data/spec/util_spec.rb +0 -52
@@ -1,22 +1,23 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'spec_helper'
3
4
 
4
- describe 'date_picker input' do
5
+ RSpec.describe 'date_picker input' do
5
6
 
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 @@ 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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 @@ describe 'date_picker input' do
71
72
  concat(f.input(:publish_at, :as => :date_picker))
72
73
  end
73
74
  )
74
- output_buffer.should 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 @@ 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should_not 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
- output_buffer.should 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
- @new_post.stub(:publish_at).and_return(@date)
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
- output_buffer.should 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 @@ 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
- output_buffer.should 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
- @new_post.stub(:publish_at).and_return(@time)
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
- output_buffer.should 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
- output_buffer.should 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
- @new_post.stub(:publish_at).and_return("")
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
- output_buffer.should 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
- output_buffer.should 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
- @new_post.stub(:publish_at).and_return("yeah")
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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should_not 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
- output_buffer.should 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 @@ describe 'date_picker input' do
256
257
  concat(f.input(:publish_at, :as => :date_picker))
257
258
  end
258
259
  )
259
- output_buffer.should_not 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
- output_buffer.should 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
- output_buffer.should 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 @@ 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should_not 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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 @@ 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 @@ 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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