formtastic 3.1.5 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +5 -5
  2. data/.gitattributes +1 -0
  3. data/.gitignore +3 -2
  4. data/.travis.yml +28 -40
  5. data/CHANGELOG.md +49 -0
  6. data/DEPRECATIONS +1 -1
  7. data/Gemfile.lock +104 -0
  8. data/README.md +628 -629
  9. data/Rakefile +20 -1
  10. data/app/assets/stylesheets/formtastic.css +1 -1
  11. data/bin/appraisal +8 -0
  12. data/formtastic.gemspec +8 -14
  13. data/gemfiles/rails_5.2/Gemfile +5 -0
  14. data/gemfiles/rails_6.0/Gemfile +5 -0
  15. data/gemfiles/rails_edge/Gemfile +13 -0
  16. data/lib/formtastic.rb +5 -11
  17. data/lib/formtastic/actions.rb +6 -3
  18. data/lib/formtastic/deprecation.rb +1 -38
  19. data/lib/formtastic/engine.rb +3 -1
  20. data/lib/formtastic/form_builder.rb +8 -24
  21. data/lib/formtastic/helpers/action_helper.rb +1 -48
  22. data/lib/formtastic/helpers/errors_helper.rb +2 -2
  23. data/lib/formtastic/helpers/fieldset_wrapper.rb +7 -3
  24. data/lib/formtastic/helpers/input_helper.rb +18 -76
  25. data/lib/formtastic/helpers/inputs_helper.rb +12 -3
  26. data/lib/formtastic/i18n.rb +1 -1
  27. data/lib/formtastic/inputs.rb +32 -29
  28. data/lib/formtastic/inputs/base/collections.rb +1 -5
  29. data/lib/formtastic/inputs/base/errors.rb +4 -4
  30. data/lib/formtastic/inputs/base/hints.rb +1 -1
  31. data/lib/formtastic/inputs/base/timeish.rb +5 -1
  32. data/lib/formtastic/inputs/base/validations.rb +19 -9
  33. data/lib/formtastic/inputs/check_boxes_input.rb +3 -3
  34. data/lib/formtastic/inputs/color_input.rb +0 -1
  35. data/lib/formtastic/inputs/select_input.rb +1 -1
  36. data/lib/formtastic/localizer.rb +5 -7
  37. data/lib/formtastic/version.rb +1 -1
  38. data/lib/generators/templates/formtastic.rb +4 -6
  39. data/script/integration-template.rb +71 -0
  40. data/script/integration.sh +19 -0
  41. data/spec/action_class_finder_spec.rb +1 -1
  42. data/spec/actions/button_action_spec.rb +8 -8
  43. data/spec/actions/generic_action_spec.rb +60 -60
  44. data/spec/actions/input_action_spec.rb +7 -7
  45. data/spec/actions/link_action_spec.rb +10 -10
  46. data/spec/builder/custom_builder_spec.rb +36 -20
  47. data/spec/builder/error_proc_spec.rb +4 -4
  48. data/spec/builder/semantic_fields_for_spec.rb +27 -27
  49. data/spec/generators/formtastic/form/form_generator_spec.rb +25 -25
  50. data/spec/generators/formtastic/input/input_generator_spec.rb +31 -31
  51. data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
  52. data/spec/helpers/action_helper_spec.rb +328 -10
  53. data/spec/helpers/actions_helper_spec.rb +17 -17
  54. data/spec/helpers/form_helper_spec.rb +33 -33
  55. data/spec/helpers/input_helper_spec.rb +975 -2
  56. data/spec/helpers/inputs_helper_spec.rb +120 -105
  57. data/spec/helpers/reflection_helper_spec.rb +3 -3
  58. data/spec/helpers/semantic_errors_helper_spec.rb +22 -22
  59. data/spec/i18n_spec.rb +26 -26
  60. data/spec/input_class_finder_spec.rb +1 -1
  61. data/spec/inputs/base/collections_spec.rb +6 -6
  62. data/spec/inputs/base/validations_spec.rb +157 -19
  63. data/spec/inputs/boolean_input_spec.rb +55 -55
  64. data/spec/inputs/check_boxes_input_spec.rb +96 -95
  65. data/spec/inputs/color_input_spec.rb +51 -63
  66. data/spec/inputs/country_input_spec.rb +20 -20
  67. data/spec/inputs/custom_input_spec.rb +2 -6
  68. data/spec/inputs/datalist_input_spec.rb +1 -1
  69. data/spec/inputs/date_picker_input_spec.rb +42 -42
  70. data/spec/inputs/date_select_input_spec.rb +51 -37
  71. data/spec/inputs/datetime_picker_input_spec.rb +46 -46
  72. data/spec/inputs/datetime_select_input_spec.rb +53 -37
  73. data/spec/inputs/email_input_spec.rb +5 -5
  74. data/spec/inputs/file_input_spec.rb +6 -6
  75. data/spec/inputs/hidden_input_spec.rb +18 -18
  76. data/spec/inputs/include_blank_spec.rb +8 -8
  77. data/spec/inputs/label_spec.rb +20 -20
  78. data/spec/inputs/number_input_spec.rb +112 -112
  79. data/spec/inputs/password_input_spec.rb +5 -5
  80. data/spec/inputs/phone_input_spec.rb +5 -5
  81. data/spec/inputs/placeholder_spec.rb +5 -5
  82. data/spec/inputs/radio_input_spec.rb +63 -65
  83. data/spec/inputs/range_input_spec.rb +66 -66
  84. data/spec/inputs/readonly_spec.rb +4 -4
  85. data/spec/inputs/search_input_spec.rb +5 -5
  86. data/spec/inputs/select_input_spec.rb +92 -96
  87. data/spec/inputs/string_input_spec.rb +23 -23
  88. data/spec/inputs/text_input_spec.rb +16 -16
  89. data/spec/inputs/time_picker_input_spec.rb +43 -43
  90. data/spec/inputs/time_select_input_spec.rb +67 -54
  91. data/spec/inputs/time_zone_input_spec.rb +19 -19
  92. data/spec/inputs/url_input_spec.rb +5 -5
  93. data/spec/inputs/with_options_spec.rb +7 -7
  94. data/spec/localizer_spec.rb +17 -17
  95. data/spec/namespaced_class_finder_spec.rb +2 -2
  96. data/spec/schema.rb +21 -0
  97. data/spec/spec_helper.rb +163 -223
  98. data/spec/support/custom_macros.rb +72 -75
  99. data/spec/support/shared_examples.rb +0 -1301
  100. data/spec/support/test_environment.rb +23 -9
  101. metadata +33 -123
  102. data/Appraisals +0 -43
  103. data/CHANGELOG +0 -54
  104. data/gemfiles/rails_3.2.gemfile +0 -9
  105. data/gemfiles/rails_4.0.4.gemfile +0 -8
  106. data/gemfiles/rails_4.1.gemfile +0 -8
  107. data/gemfiles/rails_4.2.gemfile +0 -8
  108. data/gemfiles/rails_4.gemfile +0 -8
  109. data/gemfiles/rails_5.0.gemfile +0 -8
  110. data/gemfiles/rails_edge.gemfile +0 -15
  111. data/lib/formtastic/util.rb +0 -57
  112. data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
  113. data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
  114. data/spec/util_spec.rb +0 -66
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'number input' do
4
+ RSpec.describe 'number input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -9,7 +9,7 @@ describe 'number input' do
9
9
  @output_buffer = ''
10
10
  mock_everything
11
11
 
12
- @new_post.class.stub(:validators_on).with(:title).and_return([
12
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
13
13
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
14
14
  ])
15
15
  end
@@ -82,15 +82,15 @@ describe 'number input' do
82
82
  end
83
83
 
84
84
  it 'should index the id of the wrapper' do
85
- output_buffer.should have_tag("li#post_author_attributes_3_name_input")
85
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
86
86
  end
87
87
 
88
88
  it 'should index the id of the select tag' do
89
- output_buffer.should have_tag("input#post_author_attributes_3_name")
89
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
90
90
  end
91
91
 
92
92
  it 'should index the name of the select tag' do
93
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
93
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
94
94
  end
95
95
 
96
96
  end
@@ -102,14 +102,14 @@ describe 'number input' do
102
102
  concat(semantic_form_for(@new_post) do |builder|
103
103
  concat(builder.input(:title, :as => :number, :required => true))
104
104
  end)
105
- output_buffer.should have_tag("input[@required]")
105
+ expect(output_buffer).to have_tag("input[@required]")
106
106
  end
107
107
  end
108
108
  end
109
109
 
110
110
  describe "when validations require a minimum value (:greater_than)" do
111
111
  before do
112
- @new_post.class.stub(:validators_on).with(:title).and_return([
112
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
113
113
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
114
114
  ])
115
115
  end
@@ -118,68 +118,68 @@ describe 'number input' do
118
118
  concat(semantic_form_for(@new_post) do |builder|
119
119
  builder.input(:title, :as => :number, :input_html => { :min => 5 })
120
120
  end)
121
- output_buffer.should have_tag('input[@min="5"]')
121
+ expect(output_buffer).to have_tag('input[@min="5"]')
122
122
  end
123
123
 
124
124
  it "should allow :input_html to override :min through :in" do
125
125
  concat(semantic_form_for(@new_post) do |builder|
126
126
  builder.input(:title, :as => :number, :input_html => { :in => 5..102 })
127
127
  end)
128
- output_buffer.should have_tag('input[@min="5"]')
128
+ expect(output_buffer).to have_tag('input[@min="5"]')
129
129
  end
130
130
 
131
131
  it "should allow options to override :min" do
132
132
  concat(semantic_form_for(@new_post) do |builder|
133
133
  builder.input(:title, :as => :number, :min => 5)
134
134
  end)
135
- output_buffer.should have_tag('input[@min="5"]')
135
+ expect(output_buffer).to have_tag('input[@min="5"]')
136
136
  end
137
137
 
138
138
  it "should allow options to override :min through :in" do
139
139
  concat(semantic_form_for(@new_post) do |builder|
140
140
  builder.input(:title, :as => :number, :in => 5..102)
141
141
  end)
142
- output_buffer.should have_tag('input[@min="5"]')
142
+ expect(output_buffer).to have_tag('input[@min="5"]')
143
143
  end
144
144
 
145
145
  describe "and the column is an integer" do
146
146
  before do
147
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
147
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
148
148
  end
149
149
 
150
150
  it "should add a min attribute to the input one greater than the validation" do
151
151
  concat(semantic_form_for(@new_post) do |builder|
152
152
  builder.input(:title, :as => :number)
153
153
  end)
154
- output_buffer.should have_tag('input[@min="3"]')
154
+ expect(output_buffer).to have_tag('input[@min="3"]')
155
155
  end
156
156
  end
157
157
 
158
158
  describe "and the column is a float" do
159
159
  before do
160
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
160
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
161
161
  end
162
162
 
163
163
  it "should raise an error" do
164
- lambda {
164
+ expect {
165
165
  concat(semantic_form_for(@new_post) do |builder|
166
166
  builder.input(:title, :as => :number)
167
167
  end)
168
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
168
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
169
169
  end
170
170
  end
171
171
 
172
172
  describe "and the column is a big decimal" do
173
173
  before do
174
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
174
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
175
175
  end
176
176
 
177
177
  it "should raise an error" do
178
- lambda {
178
+ expect {
179
179
  concat(semantic_form_for(@new_post) do |builder|
180
180
  builder.input(:title, :as => :number)
181
181
  end)
182
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
182
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
183
183
  end
184
184
  end
185
185
 
@@ -187,7 +187,7 @@ describe 'number input' do
187
187
 
188
188
  describe "when validations require a minimum value (:greater_than) that takes a proc" do
189
189
  before do
190
- @new_post.class.stub(:validators_on).with(:title).and_return([
190
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
191
191
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=> Proc.new {|post| 2}})
192
192
  ])
193
193
  end
@@ -196,68 +196,68 @@ describe 'number input' do
196
196
  concat(semantic_form_for(@new_post) do |builder|
197
197
  builder.input(:title, :as => :number, :input_html => { :min => 5 })
198
198
  end)
199
- output_buffer.should have_tag('input[@min="5"]')
199
+ expect(output_buffer).to have_tag('input[@min="5"]')
200
200
  end
201
201
 
202
202
  it "should allow :input_html to override :min through :in" do
203
203
  concat(semantic_form_for(@new_post) do |builder|
204
204
  builder.input(:title, :as => :number, :input_html => { :in => 5..102 })
205
205
  end)
206
- output_buffer.should have_tag('input[@min="5"]')
206
+ expect(output_buffer).to have_tag('input[@min="5"]')
207
207
  end
208
208
 
209
209
  it "should allow options to override :min" do
210
210
  concat(semantic_form_for(@new_post) do |builder|
211
211
  builder.input(:title, :as => :number, :min => 5)
212
212
  end)
213
- output_buffer.should have_tag('input[@min="5"]')
213
+ expect(output_buffer).to have_tag('input[@min="5"]')
214
214
  end
215
215
 
216
216
  it "should allow options to override :min through :in" do
217
217
  concat(semantic_form_for(@new_post) do |builder|
218
218
  builder.input(:title, :as => :number, :in => 5..102)
219
219
  end)
220
- output_buffer.should have_tag('input[@min="5"]')
220
+ expect(output_buffer).to have_tag('input[@min="5"]')
221
221
  end
222
222
 
223
223
  describe "and the column is an integer" do
224
224
  before do
225
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
225
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
226
226
  end
227
227
 
228
228
  it "should add a min attribute to the input one greater than the validation" do
229
229
  concat(semantic_form_for(@new_post) do |builder|
230
230
  builder.input(:title, :as => :number)
231
231
  end)
232
- output_buffer.should have_tag('input[@min="3"]')
232
+ expect(output_buffer).to have_tag('input[@min="3"]')
233
233
  end
234
234
  end
235
235
 
236
236
  describe "and the column is a float" do
237
237
  before do
238
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
238
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
239
239
  end
240
240
 
241
241
  it "should raise an error" do
242
- lambda {
242
+ expect {
243
243
  concat(semantic_form_for(@new_post) do |builder|
244
244
  builder.input(:title, :as => :number)
245
245
  end)
246
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
246
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
247
247
  end
248
248
  end
249
249
 
250
250
  describe "and the column is a big decimal" do
251
251
  before do
252
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
252
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
253
253
  end
254
254
 
255
255
  it "should raise an error" do
256
- lambda {
256
+ expect {
257
257
  concat(semantic_form_for(@new_post) do |builder|
258
258
  builder.input(:title, :as => :number)
259
259
  end)
260
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
260
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMinimumAttributeError)
261
261
  end
262
262
  end
263
263
 
@@ -265,7 +265,7 @@ describe 'number input' do
265
265
 
266
266
  describe "when validations require a minimum value (:greater_than_or_equal_to)" do
267
267
  before do
268
- @new_post.class.stub(:validators_on).with(:title).and_return([
268
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
269
269
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than_or_equal_to=>2})
270
270
  ])
271
271
  end
@@ -274,63 +274,63 @@ describe 'number input' do
274
274
  concat(semantic_form_for(@new_post) do |builder|
275
275
  builder.input(:title, :as => :number, :input_html => { :min => 5 })
276
276
  end)
277
- output_buffer.should have_tag('input[@min="5"]')
277
+ expect(output_buffer).to have_tag('input[@min="5"]')
278
278
  end
279
279
 
280
280
  it "should allow options to override :min" do
281
281
  concat(semantic_form_for(@new_post) do |builder|
282
282
  builder.input(:title, :as => :number, :min => 5)
283
283
  end)
284
- output_buffer.should have_tag('input[@min="5"]')
284
+ expect(output_buffer).to have_tag('input[@min="5"]')
285
285
  end
286
286
 
287
287
  it "should allow :input_html to override :min with :in" do
288
288
  concat(semantic_form_for(@new_post) do |builder|
289
289
  builder.input(:title, :as => :number, :input_html => { :in => 5..102 })
290
290
  end)
291
- output_buffer.should have_tag('input[@min="5"]')
291
+ expect(output_buffer).to have_tag('input[@min="5"]')
292
292
  end
293
293
 
294
294
  it "should allow options to override :min with :in" do
295
295
  concat(semantic_form_for(@new_post) do |builder|
296
296
  builder.input(:title, :as => :number, :in => 5..102)
297
297
  end)
298
- output_buffer.should have_tag('input[@min="5"]')
298
+ expect(output_buffer).to have_tag('input[@min="5"]')
299
299
  end
300
300
 
301
301
 
302
302
  [:integer, :decimal, :float].each do |column_type|
303
303
  describe "and the column is a #{column_type}" do
304
304
  before do
305
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
305
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
306
306
  end
307
307
 
308
308
  it "should add a max attribute to the input equal to the validation" do
309
309
  concat(semantic_form_for(@new_post) do |builder|
310
310
  builder.input(:title, :as => :number)
311
311
  end)
312
- output_buffer.should have_tag('input[@min="2"]')
312
+ expect(output_buffer).to have_tag('input[@min="2"]')
313
313
  end
314
314
  end
315
315
  end
316
316
 
317
317
  describe "and there is no column" do
318
318
  before do
319
- @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
319
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(nil)
320
320
  end
321
321
 
322
322
  it "should add a max attribute to the input equal to the validation" do
323
323
  concat(semantic_form_for(@new_post) do |builder|
324
324
  builder.input(:title, :as => :number)
325
325
  end)
326
- output_buffer.should have_tag('input[@min="2"]')
326
+ expect(output_buffer).to have_tag('input[@min="2"]')
327
327
  end
328
328
  end
329
329
  end
330
330
 
331
331
  describe "when validations require a minimum value (:greater_than_or_equal_to) that takes a Proc" do
332
332
  before do
333
- @new_post.class.stub(:validators_on).with(:title).and_return([
333
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
334
334
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than_or_equal_to=> Proc.new { |post| 2}})
335
335
  ])
336
336
  end
@@ -339,56 +339,56 @@ describe 'number input' do
339
339
  concat(semantic_form_for(@new_post) do |builder|
340
340
  builder.input(:title, :as => :number, :input_html => { :min => 5 })
341
341
  end)
342
- output_buffer.should have_tag('input[@min="5"]')
342
+ expect(output_buffer).to have_tag('input[@min="5"]')
343
343
  end
344
344
 
345
345
  it "should allow options to override :min" do
346
346
  concat(semantic_form_for(@new_post) do |builder|
347
347
  builder.input(:title, :as => :number, :min => 5)
348
348
  end)
349
- output_buffer.should have_tag('input[@min="5"]')
349
+ expect(output_buffer).to have_tag('input[@min="5"]')
350
350
  end
351
351
 
352
352
  it "should allow :input_html to override :min with :in" do
353
353
  concat(semantic_form_for(@new_post) do |builder|
354
354
  builder.input(:title, :as => :number, :input_html => { :in => 5..102 })
355
355
  end)
356
- output_buffer.should have_tag('input[@min="5"]')
356
+ expect(output_buffer).to have_tag('input[@min="5"]')
357
357
  end
358
358
 
359
359
  it "should allow options to override :min with :in" do
360
360
  concat(semantic_form_for(@new_post) do |builder|
361
361
  builder.input(:title, :as => :number, :in => 5..102)
362
362
  end)
363
- output_buffer.should have_tag('input[@min="5"]')
363
+ expect(output_buffer).to have_tag('input[@min="5"]')
364
364
  end
365
365
 
366
366
 
367
367
  [:integer, :decimal, :float].each do |column_type|
368
368
  describe "and the column is a #{column_type}" do
369
369
  before do
370
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
370
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
371
371
  end
372
372
 
373
373
  it "should add a max attribute to the input equal to the validation" do
374
374
  concat(semantic_form_for(@new_post) do |builder|
375
375
  builder.input(:title, :as => :number)
376
376
  end)
377
- output_buffer.should have_tag('input[@min="2"]')
377
+ expect(output_buffer).to have_tag('input[@min="2"]')
378
378
  end
379
379
  end
380
380
  end
381
381
 
382
382
  describe "and there is no column" do
383
383
  before do
384
- @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
384
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(nil)
385
385
  end
386
386
 
387
387
  it "should add a max attribute to the input equal to the validation" do
388
388
  concat(semantic_form_for(@new_post) do |builder|
389
389
  builder.input(:title, :as => :number)
390
390
  end)
391
- output_buffer.should have_tag('input[@min="2"]')
391
+ expect(output_buffer).to have_tag('input[@min="2"]')
392
392
  end
393
393
  end
394
394
  end
@@ -396,7 +396,7 @@ describe 'number input' do
396
396
  describe "when validations require a maximum value (:less_than)" do
397
397
 
398
398
  before do
399
- @new_post.class.stub(:validators_on).with(:title).and_return([
399
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
400
400
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=>20})
401
401
  ])
402
402
  end
@@ -405,73 +405,73 @@ describe 'number input' do
405
405
  concat(semantic_form_for(@new_post) do |builder|
406
406
  builder.input(:title, :as => :number, :input_html => { :max => 102 })
407
407
  end)
408
- output_buffer.should have_tag('input[@max="102"]')
408
+ expect(output_buffer).to have_tag('input[@max="102"]')
409
409
  end
410
410
 
411
411
  it "should allow option to override :max" do
412
412
  concat(semantic_form_for(@new_post) do |builder|
413
413
  builder.input(:title, :as => :number, :max => 102)
414
414
  end)
415
- output_buffer.should have_tag('input[@max="102"]')
415
+ expect(output_buffer).to have_tag('input[@max="102"]')
416
416
  end
417
417
 
418
418
  it "should allow :input_html to override :max with :in" do
419
419
  concat(semantic_form_for(@new_post) do |builder|
420
420
  builder.input(:title, :as => :number, :input_html => { :in => 1..102 })
421
421
  end)
422
- output_buffer.should have_tag('input[@max="102"]')
422
+ expect(output_buffer).to have_tag('input[@max="102"]')
423
423
  end
424
424
 
425
425
  it "should allow option to override :max with :in" do
426
426
  concat(semantic_form_for(@new_post) do |builder|
427
427
  builder.input(:title, :as => :number, :in => 1..102)
428
428
  end)
429
- output_buffer.should have_tag('input[@max="102"]')
429
+ expect(output_buffer).to have_tag('input[@max="102"]')
430
430
  end
431
431
 
432
432
  describe "and the column is an integer" do
433
433
  before do
434
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
434
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
435
435
  end
436
436
 
437
437
  it "should add a max attribute to the input one greater than the validation" do
438
438
  concat(semantic_form_for(@new_post) do |builder|
439
439
  builder.input(:title, :as => :number)
440
440
  end)
441
- output_buffer.should have_tag('input[@max="19"]')
441
+ expect(output_buffer).to have_tag('input[@max="19"]')
442
442
  end
443
443
  end
444
444
 
445
445
  describe "and the column is a float" do
446
446
  before do
447
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
447
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
448
448
  end
449
449
 
450
450
  it "should raise an error" do
451
- lambda {
451
+ expect {
452
452
  concat(semantic_form_for(@new_post) do |builder|
453
453
  builder.input(:title, :as => :number)
454
454
  end)
455
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
455
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
456
456
  end
457
457
  end
458
458
 
459
459
  describe "and the column is a big decimal" do
460
460
  before do
461
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
461
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
462
462
  end
463
463
 
464
464
  it "should raise an error" do
465
- lambda {
465
+ expect {
466
466
  concat(semantic_form_for(@new_post) do |builder|
467
467
  builder.input(:title, :as => :number)
468
468
  end)
469
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
469
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
470
470
  end
471
471
  end
472
472
  describe "and the validator takes a proc" do
473
473
  before do
474
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
474
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
475
475
  end
476
476
  end
477
477
  end
@@ -479,7 +479,7 @@ describe 'number input' do
479
479
  describe "when validations require a maximum value (:less_than) that takes a Proc" do
480
480
 
481
481
  before do
482
- @new_post.class.stub(:validators_on).with(:title).and_return([
482
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
483
483
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=> Proc.new {|post| 20 }})
484
484
  ])
485
485
  end
@@ -488,73 +488,73 @@ describe 'number input' do
488
488
  concat(semantic_form_for(@new_post) do |builder|
489
489
  builder.input(:title, :as => :number, :input_html => { :max => 102 })
490
490
  end)
491
- output_buffer.should have_tag('input[@max="102"]')
491
+ expect(output_buffer).to have_tag('input[@max="102"]')
492
492
  end
493
493
 
494
494
  it "should allow option to override :max" do
495
495
  concat(semantic_form_for(@new_post) do |builder|
496
496
  builder.input(:title, :as => :number, :max => 102)
497
497
  end)
498
- output_buffer.should have_tag('input[@max="102"]')
498
+ expect(output_buffer).to have_tag('input[@max="102"]')
499
499
  end
500
500
 
501
501
  it "should allow :input_html to override :max with :in" do
502
502
  concat(semantic_form_for(@new_post) do |builder|
503
503
  builder.input(:title, :as => :number, :input_html => { :in => 1..102 })
504
504
  end)
505
- output_buffer.should have_tag('input[@max="102"]')
505
+ expect(output_buffer).to have_tag('input[@max="102"]')
506
506
  end
507
507
 
508
508
  it "should allow option to override :max with :in" do
509
509
  concat(semantic_form_for(@new_post) do |builder|
510
510
  builder.input(:title, :as => :number, :in => 1..102)
511
511
  end)
512
- output_buffer.should have_tag('input[@max="102"]')
512
+ expect(output_buffer).to have_tag('input[@max="102"]')
513
513
  end
514
514
 
515
515
  describe "and the column is an integer" do
516
516
  before do
517
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
517
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
518
518
  end
519
519
 
520
520
  it "should add a max attribute to the input one greater than the validation" do
521
521
  concat(semantic_form_for(@new_post) do |builder|
522
522
  builder.input(:title, :as => :number)
523
523
  end)
524
- output_buffer.should have_tag('input[@max="19"]')
524
+ expect(output_buffer).to have_tag('input[@max="19"]')
525
525
  end
526
526
  end
527
527
 
528
528
  describe "and the column is a float" do
529
529
  before do
530
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
530
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
531
531
  end
532
532
 
533
533
  it "should raise an error" do
534
- lambda {
534
+ expect {
535
535
  concat(semantic_form_for(@new_post) do |builder|
536
536
  builder.input(:title, :as => :number)
537
537
  end)
538
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
538
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
539
539
  end
540
540
  end
541
541
 
542
542
  describe "and the column is a big decimal" do
543
543
  before do
544
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
544
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
545
545
  end
546
546
 
547
547
  it "should raise an error" do
548
- lambda {
548
+ expect {
549
549
  concat(semantic_form_for(@new_post) do |builder|
550
550
  builder.input(:title, :as => :number)
551
551
  end)
552
- }.should raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
552
+ }.to raise_error(Formtastic::Inputs::Base::Validations::IndeterminableMaximumAttributeError)
553
553
  end
554
554
  end
555
555
  describe "and the validator takes a proc" do
556
556
  before do
557
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
557
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
558
558
  end
559
559
  end
560
560
  end
@@ -562,7 +562,7 @@ describe 'number input' do
562
562
 
563
563
  describe "when validations require a maximum value (:less_than_or_equal_to)" do
564
564
  before do
565
- @new_post.class.stub(:validators_on).with(:title).and_return([
565
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
566
566
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than_or_equal_to=>20})
567
567
  ])
568
568
  end
@@ -571,62 +571,62 @@ describe 'number input' do
571
571
  concat(semantic_form_for(@new_post) do |builder|
572
572
  builder.input(:title, :as => :number, :input_html => { :max => 102 })
573
573
  end)
574
- output_buffer.should have_tag('input[@max="102"]')
574
+ expect(output_buffer).to have_tag('input[@max="102"]')
575
575
  end
576
576
 
577
577
  it "should allow options to override :max" do
578
578
  concat(semantic_form_for(@new_post) do |builder|
579
579
  builder.input(:title, :as => :number, :max => 102)
580
580
  end)
581
- output_buffer.should have_tag('input[@max="102"]')
581
+ expect(output_buffer).to have_tag('input[@max="102"]')
582
582
  end
583
583
 
584
584
  it "should allow :input_html to override :max with :in" do
585
585
  concat(semantic_form_for(@new_post) do |builder|
586
586
  builder.input(:title, :as => :number, :input_html => { :in => 1..102 })
587
587
  end)
588
- output_buffer.should have_tag('input[@max="102"]')
588
+ expect(output_buffer).to have_tag('input[@max="102"]')
589
589
  end
590
590
 
591
591
  it "should allow options to override :max with :in" do
592
592
  concat(semantic_form_for(@new_post) do |builder|
593
593
  builder.input(:title, :as => :number, :in => 1..102)
594
594
  end)
595
- output_buffer.should have_tag('input[@max="102"]')
595
+ expect(output_buffer).to have_tag('input[@max="102"]')
596
596
  end
597
597
 
598
598
  [:integer, :decimal, :float].each do |column_type|
599
599
  describe "and the column is a #{column_type}" do
600
600
  before do
601
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
601
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
602
602
  end
603
603
 
604
604
  it "should add a max attribute to the input equal to the validation" do
605
605
  concat(semantic_form_for(@new_post) do |builder|
606
606
  builder.input(:title, :as => :number)
607
607
  end)
608
- output_buffer.should have_tag('input[@max="20"]')
608
+ expect(output_buffer).to have_tag('input[@max="20"]')
609
609
  end
610
610
  end
611
611
  end
612
612
 
613
613
  describe "and there is no column" do
614
614
  before do
615
- @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
615
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(nil)
616
616
  end
617
617
 
618
618
  it "should add a max attribute to the input equal to the validation" do
619
619
  concat(semantic_form_for(@new_post) do |builder|
620
620
  builder.input(:title, :as => :number)
621
621
  end)
622
- output_buffer.should have_tag('input[@max="20"]')
622
+ expect(output_buffer).to have_tag('input[@max="20"]')
623
623
  end
624
624
  end
625
625
  end
626
626
 
627
627
  describe "when validations require a maximum value (:less_than_or_equal_to) that takes a proc" do
628
628
  before do
629
- @new_post.class.stub(:validators_on).with(:title).and_return([
629
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
630
630
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than_or_equal_to=> Proc.new { |post| 20 }})
631
631
  ])
632
632
  end
@@ -635,62 +635,62 @@ describe 'number input' do
635
635
  concat(semantic_form_for(@new_post) do |builder|
636
636
  builder.input(:title, :as => :number, :input_html => { :max => 102 })
637
637
  end)
638
- output_buffer.should have_tag('input[@max="102"]')
638
+ expect(output_buffer).to have_tag('input[@max="102"]')
639
639
  end
640
640
 
641
641
  it "should allow options to override :max" do
642
642
  concat(semantic_form_for(@new_post) do |builder|
643
643
  builder.input(:title, :as => :number, :max => 102)
644
644
  end)
645
- output_buffer.should have_tag('input[@max="102"]')
645
+ expect(output_buffer).to have_tag('input[@max="102"]')
646
646
  end
647
647
 
648
648
  it "should allow :input_html to override :max with :in" do
649
649
  concat(semantic_form_for(@new_post) do |builder|
650
650
  builder.input(:title, :as => :number, :input_html => { :in => 1..102 })
651
651
  end)
652
- output_buffer.should have_tag('input[@max="102"]')
652
+ expect(output_buffer).to have_tag('input[@max="102"]')
653
653
  end
654
654
 
655
655
  it "should allow options to override :max with :in" do
656
656
  concat(semantic_form_for(@new_post) do |builder|
657
657
  builder.input(:title, :as => :number, :in => 1..102)
658
658
  end)
659
- output_buffer.should have_tag('input[@max="102"]')
659
+ expect(output_buffer).to have_tag('input[@max="102"]')
660
660
  end
661
661
 
662
662
  [:integer, :decimal, :float].each do |column_type|
663
663
  describe "and the column is a #{column_type}" do
664
664
  before do
665
- @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
665
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
666
666
  end
667
667
 
668
668
  it "should add a max attribute to the input equal to the validation" do
669
669
  concat(semantic_form_for(@new_post) do |builder|
670
670
  builder.input(:title, :as => :number)
671
671
  end)
672
- output_buffer.should have_tag('input[@max="20"]')
672
+ expect(output_buffer).to have_tag('input[@max="20"]')
673
673
  end
674
674
  end
675
675
  end
676
676
 
677
677
  describe "and there is no column" do
678
678
  before do
679
- @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
679
+ allow(@new_post).to receive(:column_for_attribute).with(:title).and_return(nil)
680
680
  end
681
681
 
682
682
  it "should add a max attribute to the input equal to the validation" do
683
683
  concat(semantic_form_for(@new_post) do |builder|
684
684
  builder.input(:title, :as => :number)
685
685
  end)
686
- output_buffer.should have_tag('input[@max="20"]')
686
+ expect(output_buffer).to have_tag('input[@max="20"]')
687
687
  end
688
688
  end
689
689
  end
690
690
 
691
691
  describe "when validations require conflicting minimum values (:greater_than, :greater_than_or_equal_to)" do
692
692
  before do
693
- @new_post.class.stub(:validators_on).with(:title).and_return([
693
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
694
694
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than => 20, :greater_than_or_equal_to=>2})
695
695
  ])
696
696
  end
@@ -699,13 +699,13 @@ describe 'number input' do
699
699
  concat(semantic_form_for(@new_post) do |builder|
700
700
  builder.input(:title, :as => :number)
701
701
  end)
702
- output_buffer.should have_tag('input[@min="2"]')
702
+ expect(output_buffer).to have_tag('input[@min="2"]')
703
703
  end
704
704
  end
705
705
 
706
706
  describe "when validations require conflicting maximum values (:less_than, :less_than_or_equal_to)" do
707
707
  before do
708
- @new_post.class.stub(:validators_on).with(:title).and_return([
708
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
709
709
  active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than => 20, :less_than_or_equal_to=>2})
710
710
  ])
711
711
  end
@@ -714,14 +714,14 @@ describe 'number input' do
714
714
  concat(semantic_form_for(@new_post) do |builder|
715
715
  builder.input(:title, :as => :number)
716
716
  end)
717
- output_buffer.should have_tag('input[@max="2"]')
717
+ expect(output_buffer).to have_tag('input[@max="2"]')
718
718
  end
719
719
  end
720
720
 
721
721
  describe "when validations require only an integer (:only_integer)" do
722
722
 
723
723
  before do
724
- @new_post.class.stub(:validators_on).with(:title).and_return([
724
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
725
725
  active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true})
726
726
  ])
727
727
  end
@@ -730,21 +730,21 @@ describe 'number input' do
730
730
  concat(semantic_form_for(@new_post) do |builder|
731
731
  builder.input(:title, :as => :number)
732
732
  end)
733
- output_buffer.should have_tag('input[@step="1"]')
733
+ expect(output_buffer).to have_tag('input[@step="1"]')
734
734
  end
735
735
 
736
736
  it "should let input_html override :step" do
737
737
  concat(semantic_form_for(@new_post) do |builder|
738
738
  builder.input(:title, :as => :number, :input_html => { :step => 3 })
739
739
  end)
740
- output_buffer.should have_tag('input[@step="3"]')
740
+ expect(output_buffer).to have_tag('input[@step="3"]')
741
741
  end
742
742
 
743
743
  it "should let options override :step" do
744
744
  concat(semantic_form_for(@new_post) do |builder|
745
745
  builder.input(:title, :as => :number, :step => 3)
746
746
  end)
747
- output_buffer.should have_tag('input[@step="3"]')
747
+ expect(output_buffer).to have_tag('input[@step="3"]')
748
748
  end
749
749
 
750
750
  end
@@ -752,7 +752,7 @@ describe 'number input' do
752
752
  describe "when validations require a :step (non standard)" do
753
753
 
754
754
  before do
755
- @new_post.class.stub(:validators_on).with(:title).and_return([
755
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
756
756
  active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true, :step=>2})
757
757
  ])
758
758
  end
@@ -761,21 +761,21 @@ describe 'number input' do
761
761
  concat(semantic_form_for(@new_post) do |builder|
762
762
  builder.input(:title, :as => :number)
763
763
  end)
764
- output_buffer.should have_tag('input[@step="2"]')
764
+ expect(output_buffer).to have_tag('input[@step="2"]')
765
765
  end
766
766
 
767
767
  it "should let input_html override :step" do
768
768
  concat(semantic_form_for(@new_post) do |builder|
769
769
  builder.input(:title, :as => :number, :input_html => { :step => 3 })
770
770
  end)
771
- output_buffer.should have_tag('input[@step="3"]')
771
+ expect(output_buffer).to have_tag('input[@step="3"]')
772
772
  end
773
773
 
774
774
  it "should let options override :step" do
775
775
  concat(semantic_form_for(@new_post) do |builder|
776
776
  builder.input(:title, :as => :number, :step => 3)
777
777
  end)
778
- output_buffer.should have_tag('input[@step="3"]')
778
+ expect(output_buffer).to have_tag('input[@step="3"]')
779
779
  end
780
780
 
781
781
  end
@@ -783,7 +783,7 @@ describe 'number input' do
783
783
  describe "when validations do not specify :step (non standard) or :only_integer" do
784
784
 
785
785
  before do
786
- @new_post.class.stub(:validators_on).with(:title).and_return([
786
+ allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
787
787
  active_model_numericality_validator([:title], {:allow_nil=>false})
788
788
  ])
789
789
  end
@@ -792,21 +792,21 @@ describe 'number input' do
792
792
  concat(semantic_form_for(@new_post) do |builder|
793
793
  builder.input(:title, :as => :number)
794
794
  end)
795
- output_buffer.should have_tag('input[@step="any"]')
795
+ expect(output_buffer).to have_tag('input[@step="any"]')
796
796
  end
797
797
 
798
798
  it "should let input_html set :step" do
799
799
  concat(semantic_form_for(@new_post) do |builder|
800
800
  builder.input(:title, :as => :number, :input_html => { :step => 3 })
801
801
  end)
802
- output_buffer.should have_tag('input[@step="3"]')
802
+ expect(output_buffer).to have_tag('input[@step="3"]')
803
803
  end
804
804
 
805
805
  it "should let options set :step" do
806
806
  concat(semantic_form_for(@new_post) do |builder|
807
807
  builder.input(:title, :as => :number, :step => 3)
808
808
  end)
809
- output_buffer.should have_tag('input[@step="3"]')
809
+ expect(output_buffer).to have_tag('input[@step="3"]')
810
810
  end
811
811
 
812
812
  end