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 'readonly option' do
4
+ RSpec.describe 'readonly option' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -20,7 +20,7 @@ describe 'readonly option' do
20
20
  concat(semantic_form_for(@new_post) do |builder|
21
21
  concat(builder.input(:title, :as => type, input_html: {readonly: true}))
22
22
  end)
23
- output_buffer.should have_tag((type == :text ? 'textarea' : 'input') + '[@readonly]')
23
+ expect(output_buffer).to have_tag((type == :text ? 'textarea' : 'input') + '[@readonly]')
24
24
  end
25
25
  end
26
26
 
@@ -30,7 +30,7 @@ describe 'readonly option' do
30
30
  concat(semantic_form_for(@new_post) do |builder|
31
31
  concat(builder.input(:title, :as => type))
32
32
  end)
33
- output_buffer.should_not have_tag((type == :text ? 'textarea' : 'input') + '[@readonly]')
33
+ expect(output_buffer).not_to have_tag((type == :text ? 'textarea' : 'input') + '[@readonly]')
34
34
  end
35
35
  end
36
36
  describe "when column is readonly attribute" do
@@ -40,7 +40,7 @@ describe 'readonly option' do
40
40
  concat(semantic_form_for(@new_post) do |builder|
41
41
  concat(builder.input(:title, :as => type))
42
42
  end)
43
- output_buffer.should have_tag((type == :text ? 'textarea' : 'input') + '[@readonly]')
43
+ expect(output_buffer).to have_tag((type == :text ? 'textarea' : 'input') + '[@readonly]')
44
44
  end
45
45
  end
46
46
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'search input' do
4
+ RSpec.describe 'search input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -56,15 +56,15 @@ describe 'search input' do
56
56
  end
57
57
 
58
58
  it 'should index the id of the wrapper' do
59
- output_buffer.should have_tag("li#post_author_attributes_3_name_input")
59
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
60
60
  end
61
61
 
62
62
  it 'should index the id of the select tag' do
63
- output_buffer.should have_tag("input#post_author_attributes_3_name")
63
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
64
64
  end
65
65
 
66
66
  it 'should index the name of the select tag' do
67
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
67
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
68
68
  end
69
69
 
70
70
  end
@@ -75,7 +75,7 @@ describe 'search input' do
75
75
  concat(semantic_form_for(@new_post) do |builder|
76
76
  concat(builder.input(:title, :as => :search, :required => true))
77
77
  end)
78
- output_buffer.should have_tag("input[@required]")
78
+ expect(output_buffer).to have_tag("input[@required]")
79
79
  end
80
80
  end
81
81
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'select input' do
4
+ RSpec.describe 'select input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -23,10 +23,10 @@ describe 'select input' do
23
23
 
24
24
  it 'should have a option for each key and/or value' do
25
25
  @array_with_values.each do |v|
26
- output_buffer.should have_tag("form li select option[@value='#{v}']", /^#{v}$/)
26
+ expect(output_buffer).to have_tag("form li select option[@value='#{v}']", :text => /^#{v}$/)
27
27
  end
28
28
  @array_with_keys_and_values.each do |v|
29
- output_buffer.should have_tag("form li select option[@value='#{v.second}']", /^#{v.first}$/)
29
+ expect(output_buffer).to have_tag("form li select option[@value='#{v.second}']", :text => /^#{v.first}$/)
30
30
  end
31
31
  end
32
32
  end
@@ -43,26 +43,26 @@ describe 'select input' do
43
43
 
44
44
  it 'should have a option for each key and/or value' do
45
45
  @set_with_values.each do |v|
46
- output_buffer.should have_tag("form li select option[@value='#{v}']", /^#{v}$/)
46
+ expect(output_buffer).to have_tag("form li select option[@value='#{v}']", :text => /^#{v}$/)
47
47
  end
48
48
  @set_with_keys_and_values.each do |v|
49
- output_buffer.should have_tag("form li select option[@value='#{v.second}']", /^#{v.first}$/)
49
+ expect(output_buffer).to have_tag("form li select option[@value='#{v.second}']", :text => /^#{v.first}$/)
50
50
  end
51
51
  end
52
52
  end
53
53
 
54
54
  describe "using a related model without reflection's options (Mongoid Document)" do
55
55
  before do
56
- @new_post.stub(:mongoid_reviewer)
56
+ allow(@new_post).to receive(:mongoid_reviewer)
57
57
  concat(semantic_form_for(@new_post) do |builder|
58
58
  concat(builder.input(:mongoid_reviewer, :as => :select))
59
59
  end)
60
60
  end
61
61
 
62
62
  it 'should draw select options' do
63
- output_buffer.should have_tag('form li select')
64
- output_buffer.should have_tag('form li select#post_reviewer_id')
65
- output_buffer.should_not have_tag('form li select#post_mongoid_reviewer_id')
63
+ expect(output_buffer).to have_tag('form li select')
64
+ expect(output_buffer).to have_tag('form li select#post_reviewer_id')
65
+ expect(output_buffer).not_to have_tag('form li select#post_mongoid_reviewer_id')
66
66
  end
67
67
  end
68
68
 
@@ -76,7 +76,7 @@ describe 'select input' do
76
76
 
77
77
  it 'should have an option for each value' do
78
78
  @range_with_values.each do |v|
79
- output_buffer.should have_tag("form li select option[@value='#{v}']", /^#{v}$/)
79
+ expect(output_buffer).to have_tag("form li select option[@value='#{v}']", :text => /^#{v}$/)
80
80
  end
81
81
  end
82
82
  end
@@ -91,7 +91,7 @@ describe 'select input' do
91
91
 
92
92
  it 'should render select options using provided HTML string' do
93
93
  2.times do |v|
94
- output_buffer.should have_tag("form li select option[@value='#{v}']", /^#{v}$/)
94
+ expect(output_buffer).to have_tag("form li select option[@value='#{v}']", :text => /^#{v}$/)
95
95
  end
96
96
  end
97
97
  end
@@ -125,8 +125,8 @@ describe 'select input' do
125
125
  end
126
126
 
127
127
  it 'should render a select with at least options: true/false' do
128
- output_buffer.should have_tag("form li select option[@value='true']", /^Yes$/)
129
- output_buffer.should have_tag("form li select option[@value='false']", /^No$/)
128
+ expect(output_buffer).to have_tag("form li select option[@value='true']", :text => /^Yes$/)
129
+ expect(output_buffer).to have_tag("form li select option[@value='false']", :text => /^No$/)
130
130
  end
131
131
  end
132
132
 
@@ -145,18 +145,18 @@ describe 'select input' do
145
145
  end
146
146
 
147
147
  it 'should render a select with at least options: true/false' do
148
- output_buffer.should have_tag("form li select option[@value='true']", /#{@boolean_select_labels[:yes]}/)
149
- output_buffer.should have_tag("form li select option[@value='false']", /#{@boolean_select_labels[:no]}/)
148
+ expect(output_buffer).to have_tag("form li select option[@value='true']", :text => /#{@boolean_select_labels[:yes]}/)
149
+ expect(output_buffer).to have_tag("form li select option[@value='false']", :text => /#{@boolean_select_labels[:no]}/)
150
150
  end
151
151
  end
152
152
  end
153
153
 
154
154
  describe 'for a enum column' do
155
155
  before do
156
- @new_post.stub(:status) { 'inactive' }
156
+ allow(@new_post).to receive(:status) { 'inactive' }
157
157
  statuses = ActiveSupport::HashWithIndifferentAccess.new("active"=>0, "inactive"=>1)
158
- @new_post.class.stub(:statuses) { statuses }
159
- @new_post.stub(:defined_enums) { { "status" => statuses } }
158
+ allow(@new_post.class).to receive(:statuses) { statuses }
159
+ allow(@new_post).to receive(:defined_enums) { { "status" => statuses } }
160
160
  end
161
161
 
162
162
  context 'single choice' do
@@ -174,40 +174,40 @@ describe 'select input' do
174
174
  it_should_apply_error_logic_for_input_type(:select)
175
175
 
176
176
  it 'should have a select inside the wrapper' do
177
- output_buffer.should have_tag('form li select')
178
- output_buffer.should have_tag('form li select#post_status')
177
+ expect(output_buffer).to have_tag('form li select')
178
+ expect(output_buffer).to have_tag('form li select#post_status')
179
179
  end
180
180
 
181
181
  it 'should have a valid name' do
182
- output_buffer.should have_tag("form li select[@name='post[status]']")
183
- output_buffer.should_not have_tag("form li select[@name='post[status][]']")
182
+ expect(output_buffer).to have_tag("form li select[@name='post[status]']")
183
+ expect(output_buffer).not_to have_tag("form li select[@name='post[status][]']")
184
184
  end
185
185
 
186
186
  it 'should not create a multi-select' do
187
- output_buffer.should_not have_tag('form li select[@multiple]')
187
+ expect(output_buffer).not_to have_tag('form li select[@multiple]')
188
188
  end
189
189
 
190
190
  it 'should not add a hidden input' do
191
- output_buffer.should_not have_tag('form li input[@type="hidden"]')
191
+ expect(output_buffer).not_to have_tag('form li input[@type="hidden"]')
192
192
  end
193
193
 
194
194
  it 'should create a select without size' do
195
- output_buffer.should_not have_tag('form li select[@size]')
195
+ expect(output_buffer).not_to have_tag('form li select[@size]')
196
196
  end
197
197
 
198
198
  it 'should have a blank option' do
199
- output_buffer.should have_tag("form li select option[@value='']")
199
+ expect(output_buffer).to have_tag("form li select option[@value='']")
200
200
  end
201
201
 
202
202
  it 'should have a select option for each defined enum status' do
203
- output_buffer.should have_tag("form li select[@name='post[status]'] option", :count => @new_post.class.statuses.count + 1)
203
+ expect(output_buffer).to have_tag("form li select[@name='post[status]'] option", :count => @new_post.class.statuses.count + 1)
204
204
  @new_post.class.statuses.each do |label, value|
205
- output_buffer.should have_tag("form li select option[@value='#{label}']", /#{label.humanize}/)
205
+ expect(output_buffer).to have_tag("form li select option[@value='#{label}']", :text => /#{label.humanize}/)
206
206
  end
207
207
  end
208
208
 
209
209
  it 'should have one option with a "selected" attribute (TODO)' do
210
- output_buffer.should have_tag("form li select[@name='post[status]'] option[@selected]", :count => 1)
210
+ expect(output_buffer).to have_tag("form li select[@name='post[status]'] option[@selected]", :count => 1)
211
211
  end
212
212
  end
213
213
 
@@ -240,72 +240,68 @@ describe 'select input' do
240
240
  it_should_use_the_collection_when_provided(:select, 'option')
241
241
 
242
242
  it 'should have a select inside the wrapper' do
243
- output_buffer.should have_tag('form li select')
244
- output_buffer.should have_tag('form li select#post_author_id')
245
- output_buffer.should have_tag('form li select#post_reviewer_id')
243
+ expect(output_buffer).to have_tag('form li select')
244
+ expect(output_buffer).to have_tag('form li select#post_author_id')
245
+ expect(output_buffer).to have_tag('form li select#post_reviewer_id')
246
246
  end
247
247
 
248
248
  it 'should have a valid name' do
249
- output_buffer.should have_tag("form li select[@name='post[author_id]']")
250
- output_buffer.should_not have_tag("form li select[@name='post[author_id][]']")
251
- output_buffer.should_not have_tag("form li select[@name='post[reviewer_id][]']")
249
+ expect(output_buffer).to have_tag("form li select[@name='post[author_id]']")
250
+ expect(output_buffer).not_to have_tag("form li select[@name='post[author_id][]']")
251
+ expect(output_buffer).not_to have_tag("form li select[@name='post[reviewer_id][]']")
252
252
  end
253
253
 
254
254
  it 'should not create a multi-select' do
255
- output_buffer.should_not have_tag('form li select[@multiple]')
255
+ expect(output_buffer).not_to have_tag('form li select[@multiple]')
256
256
  end
257
257
 
258
258
  it 'should not add a hidden input' do
259
- output_buffer.should_not have_tag('form li input[@type="hidden"]')
259
+ expect(output_buffer).not_to have_tag('form li input[@type="hidden"]')
260
260
  end
261
261
 
262
262
  it 'should create a select without size' do
263
- output_buffer.should_not have_tag('form li select[@size]')
263
+ expect(output_buffer).not_to have_tag('form li select[@size]')
264
264
  end
265
265
 
266
266
  it 'should have a blank option' do
267
- output_buffer.should have_tag("form li select option[@value='']")
267
+ expect(output_buffer).to have_tag("form li select option[@value='']")
268
268
  end
269
269
 
270
270
  it 'should have a select option for each Author' do
271
- output_buffer.should have_tag("form li select[@name='post[author_id]'] option", :count => ::Author.all.size + 1)
271
+ expect(output_buffer).to have_tag("form li select[@name='post[author_id]'] option", :count => ::Author.all.size + 1)
272
272
  ::Author.all.each do |author|
273
- output_buffer.should have_tag("form li select option[@value='#{author.id}']", /#{author.to_label}/)
273
+ expect(output_buffer).to have_tag("form li select option[@value='#{author.id}']", :text => /#{author.to_label}/)
274
274
  end
275
275
  end
276
276
 
277
277
  it 'should have one option with a "selected" attribute (bob)' do
278
- output_buffer.should have_tag("form li select[@name='post[author_id]'] option[@selected]", :count => 1)
278
+ expect(output_buffer).to have_tag("form li select[@name='post[author_id]'] option[@selected]", :count => 1)
279
279
  end
280
280
 
281
281
  it 'should not singularize the association name' do
282
- @new_post.stub(:author_status).and_return(@bob)
283
- @new_post.stub(:author_status_id).and_return(@bob.id)
284
- @new_post.stub(:column_for_attribute).and_return(double('column', :type => :integer, :limit => 255))
282
+ allow(@new_post).to receive(:author_status).and_return(@bob)
283
+ allow(@new_post).to receive(:author_status_id).and_return(@bob.id)
284
+ allow(@new_post).to receive(:column_for_attribute).and_return(double('column', :type => :integer, :limit => 255))
285
285
 
286
286
  concat(semantic_form_for(@new_post) do |builder|
287
287
  concat(builder.input(:author_status, :as => :select))
288
288
  end)
289
289
 
290
- output_buffer.should have_tag('form li select#post_author_status_id')
290
+ expect(output_buffer).to have_tag('form li select#post_author_status_id')
291
291
  end
292
292
  end
293
293
 
294
294
  describe "for a belongs_to association with :conditions" do
295
295
  before do
296
- ::Post.stub(:reflect_on_association).with(:author) do
296
+ allow(::Post).to receive(:reflect_on_association).with(:author) do
297
297
  mock = double('reflection', :options => {:conditions => {:active => true}}, :klass => ::Author, :macro => :belongs_to)
298
- mock.stub(:[]).with(:class_name).and_return("Author")
298
+ allow(mock).to receive(:[]).with(:class_name).and_return("Author")
299
299
  mock
300
300
  end
301
301
  end
302
302
 
303
303
  it "should call author.(scoped|where) with association conditions" do
304
- if Formtastic::Util.rails3?
305
- ::Author.should_receive(:scoped).with(:conditions => {:active => true})
306
- else
307
- ::Author.should_receive(:where).with({:active => true})
308
- end
304
+ expect(::Author).to receive(:where).with({:active => true})
309
305
 
310
306
  semantic_form_for(@new_post) do |builder|
311
307
  concat(builder.input(:author, :as => :select))
@@ -329,31 +325,31 @@ describe 'select input' do
329
325
  it_should_use_the_collection_when_provided(:select, 'option')
330
326
 
331
327
  it 'should have a select inside the wrapper' do
332
- output_buffer.should have_tag('form li select')
333
- output_buffer.should have_tag('form li select#author_post_ids')
328
+ expect(output_buffer).to have_tag('form li select')
329
+ expect(output_buffer).to have_tag('form li select#author_post_ids')
334
330
  end
335
331
 
336
332
  it 'should have a multi-select select' do
337
- output_buffer.should have_tag('form li select[@multiple="multiple"]')
333
+ expect(output_buffer).to have_tag('form li select[@multiple="multiple"]')
338
334
  end
339
335
 
340
336
  it 'should append [] to the name attribute for multiple select' do
341
- output_buffer.should have_tag('form li select[@multiple="multiple"][@name="author[post_ids][]"]')
337
+ expect(output_buffer).to have_tag('form li select[@multiple="multiple"][@name="author[post_ids][]"]')
342
338
  end
343
339
 
344
340
  it 'should have a hidden field' do
345
- output_buffer.should have_tag('form li input[@type="hidden"][@name="author[post_ids][]"]', :count => 1)
341
+ expect(output_buffer).to have_tag('form li input[@type="hidden"][@name="author[post_ids][]"]', :count => 1)
346
342
  end
347
343
 
348
344
  it 'should have a select option for each Post' do
349
- output_buffer.should have_tag('form li select option', :count => ::Post.all.size)
345
+ expect(output_buffer).to have_tag('form li select option', :count => ::Post.all.size)
350
346
  ::Post.all.each do |post|
351
- output_buffer.should have_tag("form li select option[@value='#{post.id}']", /#{post.to_label}/)
347
+ expect(output_buffer).to have_tag("form li select option[@value='#{post.id}']", :text => /#{post.to_label}/)
352
348
  end
353
349
  end
354
350
 
355
351
  it 'should not have a blank option by default' do
356
- output_buffer.should_not have_tag("form li select option[@value='']")
352
+ expect(output_buffer).not_to have_tag("form li select option[@value='']")
357
353
  end
358
354
 
359
355
  it 'should respect the :include_blank option for single selects' do
@@ -361,7 +357,7 @@ describe 'select input' do
361
357
  concat(builder.input(:posts, :as => :select, :multiple => false, :include_blank => true))
362
358
  end)
363
359
 
364
- output_buffer.should have_tag("form li select option[@value='']")
360
+ expect(output_buffer).to have_tag("form li select option[@value='']")
365
361
  end
366
362
 
367
363
  it 'should respect the :include_blank option for multiple selects' do
@@ -369,11 +365,11 @@ describe 'select input' do
369
365
  concat(builder.input(:posts, :as => :select, :multiple => true, :include_blank => true))
370
366
  end)
371
367
 
372
- output_buffer.should have_tag("form li select option[@value='']")
368
+ expect(output_buffer).to have_tag("form li select option[@value='']")
373
369
  end
374
370
 
375
371
  it 'should have one option with a "selected" attribute' do
376
- output_buffer.should have_tag('form li select option[@selected]', :count => 1)
372
+ expect(output_buffer).to have_tag('form li select option[@selected]', :count => 1)
377
373
  end
378
374
  end
379
375
 
@@ -393,23 +389,23 @@ describe 'select input' do
393
389
  it_should_use_the_collection_when_provided(:select, 'option')
394
390
 
395
391
  it 'should have a select inside the wrapper' do
396
- output_buffer.should have_tag('form li select')
397
- output_buffer.should have_tag('form li select#post_author_ids')
392
+ expect(output_buffer).to have_tag('form li select')
393
+ expect(output_buffer).to have_tag('form li select#post_author_ids')
398
394
  end
399
395
 
400
396
  it 'should have a multi-select select' do
401
- output_buffer.should have_tag('form li select[@multiple="multiple"]')
397
+ expect(output_buffer).to have_tag('form li select[@multiple="multiple"]')
402
398
  end
403
399
 
404
400
  it 'should have a select option for each Author' do
405
- output_buffer.should have_tag('form li select option', :count => ::Author.all.size)
401
+ expect(output_buffer).to have_tag('form li select option', :count => ::Author.all.size)
406
402
  ::Author.all.each do |author|
407
- output_buffer.should have_tag("form li select option[@value='#{author.id}']", /#{author.to_label}/)
403
+ expect(output_buffer).to have_tag("form li select option[@value='#{author.id}']", :text => /#{author.to_label}/)
408
404
  end
409
405
  end
410
406
 
411
407
  it 'should not have a blank option by default' do
412
- output_buffer.should_not have_tag("form li select option[@value='']")
408
+ expect(output_buffer).not_to have_tag("form li select option[@value='']")
413
409
  end
414
410
 
415
411
  it 'should respect the :include_blank option for single selects' do
@@ -417,7 +413,7 @@ describe 'select input' do
417
413
  concat(builder.input(:authors, :as => :select, :multiple => false, :include_blank => true))
418
414
  end)
419
415
 
420
- output_buffer.should have_tag("form li select option[@value='']")
416
+ expect(output_buffer).to have_tag("form li select option[@value='']")
421
417
  end
422
418
 
423
419
  it 'should respect the :include_blank option for multiple selects' do
@@ -425,51 +421,51 @@ describe 'select input' do
425
421
  concat(builder.input(:authors, :as => :select, :multiple => true, :include_blank => true))
426
422
  end)
427
423
 
428
- output_buffer.should have_tag("form li select option[@value='']")
424
+ expect(output_buffer).to have_tag("form li select option[@value='']")
429
425
  end
430
426
 
431
427
  it 'should have one option with a "selected" attribute' do
432
- output_buffer.should have_tag('form li select option[@selected]', :count => 1)
428
+ expect(output_buffer).to have_tag('form li select option[@selected]', :count => 1)
433
429
  end
434
430
  end
435
431
 
436
432
  describe 'when :prompt => "choose something" is set' do
437
433
  before do
438
- @new_post.stub(:author_id).and_return(nil)
434
+ allow(@new_post).to receive(:author_id).and_return(nil)
439
435
  concat(semantic_form_for(@new_post) do |builder|
440
436
  concat(builder.input(:author, :as => :select, :prompt => "choose author"))
441
437
  end)
442
438
  end
443
439
 
444
440
  it 'should have a select with prompt' do
445
- output_buffer.should have_tag("form li select option[@value='']", /choose author/, :count => 1)
441
+ expect(output_buffer).to have_tag("form li select option[@value='']", :text => /choose author/, :count => 1)
446
442
  end
447
443
 
448
444
  it 'should not have a second blank select option' do
449
- output_buffer.should have_tag("form li select option[@value='']", :count => 1)
445
+ expect(output_buffer).to have_tag("form li select option[@value='']", :count => 1)
450
446
  end
451
447
  end
452
448
 
453
449
  describe 'when no object is given' do
454
- before(:each) do
450
+ before(:example) do
455
451
  concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
456
452
  concat(builder.input(:author, :as => :select, :collection => ::Author.all))
457
453
  end)
458
454
  end
459
455
 
460
456
  it 'should generate label' do
461
- output_buffer.should have_tag('form li label', /Author/)
462
- output_buffer.should have_tag("form li label[@for='project_author']")
457
+ expect(output_buffer).to have_tag('form li label', :text => /Author/)
458
+ expect(output_buffer).to have_tag("form li label[@for='project_author']")
463
459
  end
464
460
 
465
461
  it 'should generate select inputs' do
466
- output_buffer.should have_tag('form li select#project_author')
467
- output_buffer.should have_tag('form li select option', :count => ::Author.all.size + 1)
462
+ expect(output_buffer).to have_tag('form li select#project_author')
463
+ expect(output_buffer).to have_tag('form li select option', :count => ::Author.all.size + 1)
468
464
  end
469
465
 
470
466
  it 'should generate an option to each item' do
471
467
  ::Author.all.each do |author|
472
- output_buffer.should have_tag("form li select option[@value='#{author.id}']", /#{author.to_label}/)
468
+ expect(output_buffer).to have_tag("form li select option[@value='#{author.id}']", :text => /#{author.to_label}/)
473
469
  end
474
470
  end
475
471
  end
@@ -480,7 +476,7 @@ describe 'select input' do
480
476
  concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
481
477
  concat(builder.input(:author_name, :as => :select, :collection => ::Author.all))
482
478
  end)
483
- output_buffer.should have_tag("form li select[@name='project[author_name]']")
479
+ expect(output_buffer).to have_tag("form li select[@name='project[author_name]']")
484
480
  end
485
481
 
486
482
  describe 'and :multiple is set to true through :input_html' do
@@ -488,7 +484,7 @@ describe 'select input' do
488
484
  concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
489
485
  concat(builder.input(:author_name, :as => :select, :input_html => {:multiple => true} ))
490
486
  end)
491
- output_buffer.should have_tag("form li select[@multiple]")
487
+ expect(output_buffer).to have_tag("form li select[@multiple]")
492
488
  end
493
489
  end
494
490
 
@@ -497,14 +493,14 @@ describe 'select input' do
497
493
  concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
498
494
  concat(builder.input(:author_name, :as => :select, :multiple => true, :collection => ["Fred", "Bob"]))
499
495
  end)
500
- output_buffer.should have_tag("form li select[@multiple]")
496
+ expect(output_buffer).to have_tag("form li select[@multiple]")
501
497
  end
502
498
  end
503
499
 
504
500
  end
505
501
 
506
502
  describe 'when a grouped collection collection is given' do
507
- before(:each) do
503
+ before(:example) do
508
504
  concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
509
505
  @grouped_opts = [['one', ['pencil', 'crayon', 'pen']],
510
506
  ['two', ['eyes', 'hands', 'feet']],
@@ -515,12 +511,12 @@ describe 'select input' do
515
511
 
516
512
  it 'should generate an option to each item' do
517
513
  @grouped_opts.each do |opt_pair|
518
- output_buffer.should have_tag("form li select optgroup[@label='#{opt_pair[0]}']")
514
+ expect(output_buffer).to have_tag("form li select optgroup[@label='#{opt_pair[0]}']")
519
515
  opt_pair[1].each do |v|
520
- output_buffer.should have_tag("form li select optgroup[@label='#{opt_pair[0]}'] option[@value='#{v}']")
516
+ expect(output_buffer).to have_tag("form li select optgroup[@label='#{opt_pair[0]}'] option[@value='#{v}']")
521
517
  end
522
518
  end
523
- output_buffer.should have_tag("form li select optgroup option[@selected]","hands")
519
+ expect(output_buffer).to have_tag("form li select optgroup option[@selected]","hands")
524
520
  end
525
521
  end
526
522
 
@@ -528,7 +524,7 @@ describe 'select input' do
528
524
  before do
529
525
  @output_buffer = ''
530
526
  @some_meta_descriptions = ["One", "Two", "Three"]
531
- @new_post.stub(:meta_description).at_least(:once)
527
+ allow(@new_post).to receive(:meta_description).at_least(:once)
532
528
  end
533
529
 
534
530
  describe ":as is not set" do
@@ -542,7 +538,7 @@ describe 'select input' do
542
538
  end
543
539
 
544
540
  it "should render a select field" do
545
- output_buffer.should have_tag("form li select", :count => 2)
541
+ expect(output_buffer).to have_tag("form li select", :count => 2)
546
542
  end
547
543
  end
548
544
 
@@ -558,7 +554,7 @@ describe 'select input' do
558
554
  end
559
555
 
560
556
  it "should render a text field" do
561
- output_buffer.should have_tag("form li input[@type='text']", :count => 2)
557
+ expect(output_buffer).to have_tag("form li input[@type='text']", :count => 2)
562
558
  end
563
559
  end
564
560
  end
@@ -588,15 +584,15 @@ describe 'select input' do
588
584
  end
589
585
 
590
586
  it 'should index the id of the wrapper' do
591
- output_buffer.should have_tag("li#post_author_attributes_3_name_input")
587
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
592
588
  end
593
589
 
594
590
  it 'should index the id of the select tag' do
595
- output_buffer.should have_tag("select#post_author_attributes_3_name")
591
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_name")
596
592
  end
597
593
 
598
594
  it 'should index the name of the select' do
599
- output_buffer.should have_tag("select[@name='post[author_attributes][3][name]']")
595
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][name]']")
600
596
  end
601
597
 
602
598
  end
@@ -607,7 +603,7 @@ describe 'select input' do
607
603
  concat(semantic_form_for(@new_post) do |builder|
608
604
  concat(builder.input(:author, :as => :select, :required => true))
609
605
  end)
610
- output_buffer.should have_tag("select[@required]")
606
+ expect(output_buffer).to have_tag("select[@required]")
611
607
  end
612
608
  end
613
609
  end