formtastic 3.1.2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/test.yml +61 -0
  4. data/.gitignore +3 -2
  5. data/CHANGELOG.md +52 -0
  6. data/Gemfile.lock +105 -0
  7. data/MIT-LICENSE +1 -1
  8. data/{README.textile → README.md} +178 -167
  9. data/RELEASE_PROCESS +3 -1
  10. data/Rakefile +20 -1
  11. data/app/assets/stylesheets/formtastic.css +1 -1
  12. data/bin/appraisal +8 -0
  13. data/formtastic.gemspec +10 -16
  14. data/gemfiles/rails_5.2/Gemfile +5 -0
  15. data/gemfiles/rails_6.0/Gemfile +5 -0
  16. data/gemfiles/rails_6.1/Gemfile +5 -0
  17. data/gemfiles/rails_edge/Gemfile +13 -0
  18. data/lib/formtastic.rb +9 -11
  19. data/lib/formtastic/actions.rb +6 -3
  20. data/lib/formtastic/deprecation.rb +1 -38
  21. data/lib/formtastic/engine.rb +3 -1
  22. data/lib/formtastic/form_builder.rb +11 -24
  23. data/lib/formtastic/helpers.rb +1 -1
  24. data/lib/formtastic/helpers/action_helper.rb +1 -48
  25. data/lib/formtastic/helpers/enum.rb +13 -0
  26. data/lib/formtastic/helpers/errors_helper.rb +2 -2
  27. data/lib/formtastic/helpers/fieldset_wrapper.rb +13 -9
  28. data/lib/formtastic/helpers/form_helper.rb +1 -1
  29. data/lib/formtastic/helpers/input_helper.rb +23 -77
  30. data/lib/formtastic/helpers/inputs_helper.rb +27 -22
  31. data/lib/formtastic/i18n.rb +1 -1
  32. data/lib/formtastic/inputs.rb +32 -29
  33. data/lib/formtastic/inputs/base/choices.rb +1 -1
  34. data/lib/formtastic/inputs/base/collections.rb +43 -10
  35. data/lib/formtastic/inputs/base/database.rb +7 -2
  36. data/lib/formtastic/inputs/base/errors.rb +4 -4
  37. data/lib/formtastic/inputs/base/hints.rb +1 -1
  38. data/lib/formtastic/inputs/base/html.rb +7 -6
  39. data/lib/formtastic/inputs/base/naming.rb +4 -4
  40. data/lib/formtastic/inputs/base/options.rb +2 -3
  41. data/lib/formtastic/inputs/base/timeish.rb +5 -1
  42. data/lib/formtastic/inputs/base/validations.rb +38 -12
  43. data/lib/formtastic/inputs/check_boxes_input.rb +13 -5
  44. data/lib/formtastic/inputs/color_input.rb +0 -1
  45. data/lib/formtastic/inputs/country_input.rb +3 -1
  46. data/lib/formtastic/inputs/radio_input.rb +20 -0
  47. data/lib/formtastic/inputs/select_input.rb +29 -1
  48. data/lib/formtastic/inputs/time_zone_input.rb +16 -6
  49. data/lib/formtastic/localizer.rb +20 -22
  50. data/lib/formtastic/namespaced_class_finder.rb +1 -1
  51. data/lib/formtastic/version.rb +1 -1
  52. data/lib/generators/formtastic/form/form_generator.rb +1 -1
  53. data/lib/generators/formtastic/input/input_generator.rb +46 -0
  54. data/lib/generators/templates/formtastic.rb +14 -13
  55. data/lib/generators/templates/input.rb +19 -0
  56. data/sample/basic_inputs.html +1 -1
  57. data/script/integration-template.rb +74 -0
  58. data/script/integration.sh +19 -0
  59. data/spec/action_class_finder_spec.rb +1 -1
  60. data/spec/actions/button_action_spec.rb +8 -8
  61. data/spec/actions/generic_action_spec.rb +60 -60
  62. data/spec/actions/input_action_spec.rb +7 -7
  63. data/spec/actions/link_action_spec.rb +10 -10
  64. data/spec/builder/custom_builder_spec.rb +37 -21
  65. data/spec/builder/error_proc_spec.rb +4 -4
  66. data/spec/builder/semantic_fields_for_spec.rb +27 -27
  67. data/spec/fast_spec_helper.rb +12 -0
  68. data/spec/generators/formtastic/form/form_generator_spec.rb +25 -25
  69. data/spec/generators/formtastic/input/input_generator_spec.rb +124 -0
  70. data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
  71. data/spec/helpers/action_helper_spec.rb +328 -10
  72. data/spec/helpers/actions_helper_spec.rb +17 -17
  73. data/spec/helpers/form_helper_spec.rb +37 -37
  74. data/spec/helpers/input_helper_spec.rb +975 -2
  75. data/spec/helpers/inputs_helper_spec.rb +120 -105
  76. data/spec/helpers/reflection_helper_spec.rb +3 -3
  77. data/spec/helpers/semantic_errors_helper_spec.rb +22 -22
  78. data/spec/i18n_spec.rb +26 -26
  79. data/spec/input_class_finder_spec.rb +1 -1
  80. data/spec/inputs/base/collections_spec.rb +76 -0
  81. data/spec/inputs/base/validations_spec.rb +480 -0
  82. data/spec/inputs/boolean_input_spec.rb +55 -55
  83. data/spec/inputs/check_boxes_input_spec.rb +155 -108
  84. data/spec/inputs/color_input_spec.rb +51 -63
  85. data/spec/inputs/country_input_spec.rb +20 -20
  86. data/spec/inputs/custom_input_spec.rb +2 -6
  87. data/spec/inputs/datalist_input_spec.rb +1 -1
  88. data/spec/inputs/date_picker_input_spec.rb +42 -42
  89. data/spec/inputs/date_select_input_spec.rb +51 -37
  90. data/spec/inputs/datetime_picker_input_spec.rb +46 -46
  91. data/spec/inputs/datetime_select_input_spec.rb +53 -37
  92. data/spec/inputs/email_input_spec.rb +5 -5
  93. data/spec/inputs/file_input_spec.rb +6 -6
  94. data/spec/inputs/hidden_input_spec.rb +18 -18
  95. data/spec/inputs/include_blank_spec.rb +8 -8
  96. data/spec/inputs/label_spec.rb +20 -20
  97. data/spec/inputs/number_input_spec.rb +112 -112
  98. data/spec/inputs/password_input_spec.rb +5 -5
  99. data/spec/inputs/phone_input_spec.rb +5 -5
  100. data/spec/inputs/placeholder_spec.rb +5 -5
  101. data/spec/inputs/radio_input_spec.rb +84 -58
  102. data/spec/inputs/range_input_spec.rb +66 -66
  103. data/spec/inputs/readonly_spec.rb +50 -0
  104. data/spec/inputs/search_input_spec.rb +5 -5
  105. data/spec/inputs/select_input_spec.rb +149 -93
  106. data/spec/inputs/string_input_spec.rb +23 -23
  107. data/spec/inputs/text_input_spec.rb +16 -16
  108. data/spec/inputs/time_picker_input_spec.rb +43 -43
  109. data/spec/inputs/time_select_input_spec.rb +67 -54
  110. data/spec/inputs/time_zone_input_spec.rb +54 -28
  111. data/spec/inputs/url_input_spec.rb +5 -5
  112. data/spec/inputs/with_options_spec.rb +7 -7
  113. data/spec/localizer_spec.rb +17 -17
  114. data/spec/namespaced_class_finder_spec.rb +2 -2
  115. data/spec/schema.rb +21 -0
  116. data/spec/spec_helper.rb +165 -253
  117. data/spec/support/custom_macros.rb +72 -75
  118. data/spec/support/shared_examples.rb +0 -1232
  119. data/spec/support/test_environment.rb +23 -9
  120. metadata +69 -176
  121. data/.travis.yml +0 -29
  122. data/Appraisals +0 -29
  123. data/CHANGELOG +0 -31
  124. data/DEPRECATIONS +0 -49
  125. data/gemfiles/rails_3.2.gemfile +0 -7
  126. data/gemfiles/rails_4.0.4.gemfile +0 -7
  127. data/gemfiles/rails_4.1.gemfile +0 -7
  128. data/gemfiles/rails_4.2.gemfile +0 -7
  129. data/gemfiles/rails_4.gemfile +0 -7
  130. data/gemfiles/rails_edge.gemfile +0 -10
  131. data/lib/formtastic/util.rb +0 -57
  132. data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
  133. data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
  134. data/spec/support/deferred_garbage_collection.rb +0 -21
  135. data/spec/util_spec.rb +0 -66
@@ -10,67 +10,67 @@ module CustomMacros
10
10
 
11
11
  def it_should_have_input_wrapper_with_class(class_name)
12
12
  it "should have input wrapper with class '#{class_name}'" do
13
- output_buffer.should have_tag("form li.#{class_name}")
13
+ expect(output_buffer).to have_tag("form li.#{class_name}")
14
14
  end
15
15
  end
16
16
 
17
17
  def it_should_have_input_wrapper_with_id(id_string)
18
18
  it "should have input wrapper with id '#{id_string}'" do
19
- output_buffer.should have_tag("form li##{id_string}")
19
+ expect(output_buffer).to have_tag("form li##{id_string}")
20
20
  end
21
21
  end
22
22
 
23
23
  def it_should_not_have_a_label
24
24
  it "should not have a label" do
25
- output_buffer.should_not have_tag("form li label")
25
+ expect(output_buffer).not_to have_tag("form li label")
26
26
  end
27
27
  end
28
28
 
29
29
  def it_should_have_a_nested_fieldset
30
30
  it "should have a nested_fieldset" do
31
- output_buffer.should have_tag("form li fieldset")
31
+ expect(output_buffer).to have_tag("form li fieldset")
32
32
  end
33
33
  end
34
34
 
35
35
  def it_should_have_a_nested_fieldset_with_class(klass)
36
36
  it "should have a nested_fieldset with class #{klass}" do
37
- output_buffer.should have_tag("form li fieldset.#{klass}")
37
+ expect(output_buffer).to have_tag("form li fieldset.#{klass}")
38
38
  end
39
39
  end
40
40
 
41
41
  def it_should_have_a_nested_ordered_list_with_class(klass)
42
42
  it "should have a nested fieldset with class #{klass}" do
43
- output_buffer.should have_tag("form li ol.#{klass}")
43
+ expect(output_buffer).to have_tag("form li ol.#{klass}")
44
44
  end
45
45
  end
46
46
 
47
47
  def it_should_have_label_with_text(string_or_regex)
48
48
  it "should have a label with text '#{string_or_regex}'" do
49
- output_buffer.should have_tag("form li label", string_or_regex)
49
+ expect(output_buffer).to have_tag("form li label", :text => string_or_regex)
50
50
  end
51
51
  end
52
52
 
53
53
  def it_should_have_label_for(element_id)
54
54
  it "should have a label for ##{element_id}" do
55
- output_buffer.should have_tag("form li label.label[@for='#{element_id}']")
55
+ expect(output_buffer).to have_tag("form li label.label[@for='#{element_id}']")
56
56
  end
57
57
  end
58
58
 
59
59
  def it_should_have_an_inline_label_for(element_id)
60
60
  it "should have a label for ##{element_id}" do
61
- output_buffer.should have_tag("form li label[@for='#{element_id}']")
61
+ expect(output_buffer).to have_tag("form li label[@for='#{element_id}']")
62
62
  end
63
63
  end
64
64
 
65
65
  def it_should_have_input_with_id(element_id)
66
66
  it "should have an input with id '#{element_id}'" do
67
- output_buffer.should have_tag("form li input##{element_id}")
67
+ expect(output_buffer).to have_tag("form li input##{element_id}")
68
68
  end
69
69
  end
70
70
 
71
71
  def it_should_have_select_with_id(element_id)
72
72
  it "should have a select box with id '#{element_id}'" do
73
- output_buffer.should have_tag("form li select##{element_id}")
73
+ expect(output_buffer).to have_tag("form li select##{element_id}")
74
74
  end
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ module CustomMacros
78
78
  def it_should_have_tag_with(type, attribute_value_hash)
79
79
  attribute_value_hash.each do |attribute, value|
80
80
  it "should have a #{type} box with #{attribute} '#{value}'" do
81
- output_buffer.should have_tag("form li #{type}[@#{attribute}=\"#{value}\"]")
81
+ expect(output_buffer).to have_tag("form li #{type}[@#{attribute}=\"#{value}\"]")
82
82
  end
83
83
  end
84
84
  end
@@ -88,44 +88,44 @@ module CustomMacros
88
88
 
89
89
  def it_should_have_many_tags(type, count)
90
90
  it "should have #{count} #{type} tags" do
91
- output_buffer.should have_tag("form li #{type}", count: count)
91
+ expect(output_buffer).to have_tag("form li #{type}", count: count)
92
92
  end
93
93
  end
94
94
 
95
95
  def it_should_have_input_with_type(input_type)
96
96
  it "should have a #{input_type} input" do
97
- output_buffer.should have_tag("form li input[@type=\"#{input_type}\"]")
97
+ expect(output_buffer).to have_tag("form li input[@type=\"#{input_type}\"]")
98
98
  end
99
99
  end
100
100
 
101
101
  def it_should_have_input_with_name(name)
102
102
  it "should have an input named #{name}" do
103
- output_buffer.should have_tag("form li input[@name=\"#{name}\"]")
103
+ expect(output_buffer).to have_tag("form li input[@name=\"#{name}\"]")
104
104
  end
105
105
  end
106
106
 
107
107
  def it_should_have_select_with_name(name)
108
108
  it "should have an input named #{name}" do
109
- output_buffer.should have_tag("form li select[@name=\"#{name}\"]")
109
+ expect(output_buffer).to have_tag("form li select[@name=\"#{name}\"]")
110
110
  end
111
111
  end
112
112
 
113
113
  def it_should_have_textarea_with_name(name)
114
114
  it "should have an input named #{name}" do
115
- output_buffer.should have_tag("form li textarea[@name=\"#{name}\"]")
115
+ expect(output_buffer).to have_tag("form li textarea[@name=\"#{name}\"]")
116
116
  end
117
117
  end
118
118
 
119
119
  def it_should_have_textarea_with_id(element_id)
120
120
  it "should have an input with id '#{element_id}'" do
121
- output_buffer.should have_tag("form li textarea##{element_id}")
121
+ expect(output_buffer).to have_tag("form li textarea##{element_id}")
122
122
  end
123
123
  end
124
124
 
125
125
  def it_should_have_label_and_input_with_id(element_id)
126
126
  it "should have an input with id '#{element_id}'" do
127
- output_buffer.should have_tag("form li input##{element_id}")
128
- output_buffer.should have_tag("form li label[@for='#{element_id}']")
127
+ expect(output_buffer).to have_tag("form li input##{element_id}")
128
+ expect(output_buffer).to have_tag("form li label[@for='#{element_id}']")
129
129
  end
130
130
  end
131
131
 
@@ -135,7 +135,7 @@ module CustomMacros
135
135
  concat(semantic_form_for(@new_post) do |builder|
136
136
  concat(builder.input(:title, :as => as))
137
137
  end)
138
- output_buffer.should have_tag("form li input[@size='#{Formtastic::FormBuilder.default_text_field_size}']")
138
+ expect(output_buffer).to have_tag("form li input[@size='#{Formtastic::FormBuilder.default_text_field_size}']")
139
139
  end
140
140
  end
141
141
  end
@@ -146,8 +146,8 @@ module CustomMacros
146
146
  concat(semantic_form_for(@new_post) do |builder|
147
147
  concat(builder.input(:title, :as => as))
148
148
  end)
149
- output_buffer.should have_tag("form li input")
150
- output_buffer.should_not have_tag("form li input[@size]")
149
+ expect(output_buffer).to have_tag("form li input")
150
+ expect(output_buffer).not_to have_tag("form li input[@size]")
151
151
  end
152
152
  end
153
153
  end
@@ -157,7 +157,7 @@ module CustomMacros
157
157
  concat(semantic_form_for(@new_post) do |builder|
158
158
  concat(builder.input(:title, :as => as, :input_html => { :class => 'myclass' }))
159
159
  end)
160
- output_buffer.should have_tag("form li input.myclass")
160
+ expect(output_buffer).to have_tag("form li input.myclass")
161
161
  end
162
162
  end
163
163
 
@@ -166,27 +166,28 @@ module CustomMacros
166
166
  concat(semantic_form_for(@new_post) do |builder|
167
167
  concat(builder.input(:title, :as => as, :input_html => { :id => 'myid' }))
168
168
  end)
169
- output_buffer.should have_tag('form li label[@for="myid"]')
169
+ expect(output_buffer).to have_tag('form li label[@for="myid"]')
170
170
  end
171
171
  end
172
172
 
173
173
  def it_should_have_maxlength_matching_column_limit
174
174
  it 'should have a maxlength matching column limit' do
175
- @new_post.column_for_attribute(:title).limit.should == 50
176
- output_buffer.should have_tag("form li input[@maxlength='50']")
175
+ expect(@new_post.column_for_attribute(:title).limit).to eq(50)
176
+ expect(output_buffer).to have_tag("form li input[@maxlength='50']")
177
177
  end
178
178
  end
179
179
 
180
180
  def it_should_use_column_size_for_columns_shorter_than_default_text_field_size(as)
181
181
  it 'should use the column size for columns shorter than default_text_field_size' do
182
182
  column_limit_shorted_than_default = 1
183
- @new_post.stub(:column_for_attribute).and_return(double('column', :type => as, :limit => column_limit_shorted_than_default))
183
+ allow(@new_post).to receive(:column_for_attribute)
184
+ .and_return(double('column', :type => as, :limit => column_limit_shorted_than_default))
184
185
 
185
186
  concat(semantic_form_for(@new_post) do |builder|
186
187
  concat(builder.input(:title, :as => as))
187
188
  end)
188
189
 
189
- output_buffer.should have_tag("form li input[@size='#{column_limit_shorted_than_default}']")
190
+ expect(output_buffer).to have_tag("form li input[@size='#{column_limit_shorted_than_default}']")
190
191
  end
191
192
  end
192
193
 
@@ -195,25 +196,25 @@ module CustomMacros
195
196
  before do
196
197
  @title_errors = ['must not be blank', 'must be longer than 10 characters', 'must be awesome']
197
198
  @errors = double('errors')
198
- @errors.stub(:[]).with(errors_matcher(:title)).and_return(@title_errors)
199
+ allow(@errors).to receive(:[]).with(errors_matcher(:title)).and_return(@title_errors)
199
200
  Formtastic::FormBuilder.file_metadata_suffixes.each do |suffix|
200
- @errors.stub(:[]).with(errors_matcher("title_#{suffix}".to_sym)).and_return(nil)
201
+ allow(@errors).to receive(:[]).with(errors_matcher("title_#{suffix}".to_sym)).and_return(nil)
201
202
  end
202
- @new_post.stub(:errors).and_return(@errors)
203
+ allow(@new_post).to receive(:errors).and_return(@errors)
203
204
  end
204
205
 
205
206
  it 'should apply an errors class to the list item' do
206
207
  concat(semantic_form_for(@new_post) do |builder|
207
208
  concat(builder.input(:title, :as => type))
208
209
  end)
209
- output_buffer.should have_tag('form li.error')
210
+ expect(output_buffer).to have_tag('form li.error')
210
211
  end
211
212
 
212
213
  it 'should not wrap the input with the Rails default error wrapping' do
213
214
  concat(semantic_form_for(@new_post) do |builder|
214
215
  concat(builder.input(:title, :as => type))
215
216
  end)
216
- output_buffer.should_not have_tag('div.fieldWithErrors')
217
+ expect(output_buffer).not_to have_tag('div.fieldWithErrors')
217
218
  end
218
219
 
219
220
  it 'should render a paragraph for the errors' do
@@ -221,7 +222,7 @@ module CustomMacros
221
222
  concat(semantic_form_for(@new_post) do |builder|
222
223
  concat(builder.input(:title, :as => type))
223
224
  end)
224
- output_buffer.should have_tag('form li.error p.inline-errors')
225
+ expect(output_buffer).to have_tag('form li.error p.inline-errors')
225
226
  end
226
227
 
227
228
  it 'should not display an error list' do
@@ -229,7 +230,7 @@ module CustomMacros
229
230
  concat(semantic_form_for(@new_post) do |builder|
230
231
  concat(builder.input(:title, :as => type))
231
232
  end)
232
- output_buffer.should have_tag('form li.error ul.errors')
233
+ expect(output_buffer).to have_tag('form li.error ul.errors')
233
234
  end
234
235
  end
235
236
 
@@ -241,15 +242,15 @@ module CustomMacros
241
242
  end
242
243
 
243
244
  it 'should not apply an errors class to the list item' do
244
- output_buffer.should_not have_tag('form li.error')
245
+ expect(output_buffer).not_to have_tag('form li.error')
245
246
  end
246
247
 
247
248
  it 'should not render a paragraph for the errors' do
248
- output_buffer.should_not have_tag('form li.error p.inline-errors')
249
+ expect(output_buffer).not_to have_tag('form li.error p.inline-errors')
249
250
  end
250
251
 
251
252
  it 'should not display an error list' do
252
- output_buffer.should_not have_tag('form li.error ul.errors')
253
+ expect(output_buffer).not_to have_tag('form li.error ul.errors')
253
254
  end
254
255
  end
255
256
 
@@ -261,26 +262,22 @@ module CustomMacros
261
262
  end
262
263
 
263
264
  it 'should not apply an errors class to the list item' do
264
- output_buffer.should_not have_tag('form li.error')
265
+ expect(output_buffer).not_to have_tag('form li.error')
265
266
  end
266
267
 
267
268
  it 'should not render a paragraph for the errors' do
268
- output_buffer.should_not have_tag('form li.error p.inline-errors')
269
+ expect(output_buffer).not_to have_tag('form li.error p.inline-errors')
269
270
  end
270
271
 
271
272
  it 'should not display an error list' do
272
- output_buffer.should_not have_tag('form li.error ul.errors')
273
+ expect(output_buffer).not_to have_tag('form li.error ul.errors')
273
274
  end
274
275
  end
275
276
  end
276
277
 
277
278
  def it_should_call_find_on_association_class_when_no_collection_is_provided(as)
278
279
  it "should call find on the association class when no collection is provided" do
279
- if Formtastic::Util.rails3?
280
- ::Author.should_receive(:scoped)
281
- else
282
- ::Author.should_receive(:where)
283
- end
280
+ expect(::Author).to receive(:where)
284
281
  concat(semantic_form_for(@new_post) do |builder|
285
282
  concat(builder.input(:author, :as => as))
286
283
  end)
@@ -299,7 +296,7 @@ module CustomMacros
299
296
  concat(semantic_form_for(@new_post) do |builder|
300
297
  concat(builder.input(:author, :as => as, :collection => @authors))
301
298
  end)
302
- output_buffer.should have_tag("form li.#{as} #{countable}", :count => @authors.size + (as == :select ? 1 : 0))
299
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}", :count => @authors.size + (as == :select ? 1 : 0))
303
300
  end
304
301
 
305
302
  describe 'and the :collection is an array of strings' do
@@ -313,24 +310,24 @@ module CustomMacros
313
310
  end)
314
311
 
315
312
  @categories.each do |value|
316
- output_buffer.should have_tag("form li.#{as}", /#{value}/)
317
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value}']")
313
+ expect(output_buffer).to have_tag("form li.#{as}", :text => /#{value}/)
314
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{value}']")
318
315
  end
319
316
  end
320
317
 
321
318
  if as == :radio
322
319
  it 'should generate a sanitized label for attribute' do
323
- @bob.stub(:category_name).and_return(@categories)
320
+ allow(@bob).to receive(:category_name).and_return(@categories)
324
321
  concat(semantic_form_for(@new_post) do |builder|
325
322
  fields = builder.semantic_fields_for(@bob) do |bob_builder|
326
323
  concat(bob_builder.input(:category_name, :as => as, :collection => @categories))
327
324
  end
328
325
  concat(fields)
329
326
  end)
330
- output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_general']")
331
- output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_design']")
332
- output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_development']")
333
- output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_quasi-serious_inventions']")
327
+ expect(output_buffer).to have_tag("form li fieldset ol li label[@for='post_author_category_name_general']")
328
+ expect(output_buffer).to have_tag("form li fieldset ol li label[@for='post_author_category_name_design']")
329
+ expect(output_buffer).to have_tag("form li fieldset ol li label[@for='post_author_category_name_development']")
330
+ expect(output_buffer).to have_tag("form li fieldset ol li label[@for='post_author_category_name_quasi-serious_inventions']")
334
331
  end
335
332
  end
336
333
  end
@@ -346,8 +343,8 @@ module CustomMacros
346
343
  end)
347
344
 
348
345
  @categories.each do |label, value|
349
- output_buffer.should have_tag("form li.#{as}", /#{label}/)
350
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value}']")
346
+ expect(output_buffer).to have_tag("form li.#{as}", :text => /#{label}/)
347
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{value}']")
351
348
  end
352
349
  end
353
350
  end
@@ -364,9 +361,9 @@ module CustomMacros
364
361
 
365
362
  @categories.each do |text, value|
366
363
  label = as == :select ? :option : :label
367
- output_buffer.should have_tag("form li.#{as} #{label}", /#{text}/i)
368
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value.to_s}']")
369
- output_buffer.should have_tag("form li.#{as} #{countable}#post_category_name_#{value.to_s}") if as == :radio
364
+ expect(output_buffer).to have_tag("form li.#{as} #{label}", :text => /#{text}/i)
365
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{value.to_s}']")
366
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}#post_category_name_#{value.to_s}") if as == :radio
370
367
  end
371
368
  end
372
369
  end
@@ -382,8 +379,8 @@ module CustomMacros
382
379
  concat(builder.input(:category_name, :as => as, :collection => @choices))
383
380
  end)
384
381
 
385
- output_buffer.should have_tag("form li.#{as} #{countable}#post_category_name_true")
386
- output_buffer.should have_tag("form li.#{as} #{countable}#post_category_name_false")
382
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}#post_category_name_true")
383
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}#post_category_name_false")
387
384
  end
388
385
  end
389
386
  end
@@ -400,8 +397,8 @@ module CustomMacros
400
397
 
401
398
  @categories.each do |value|
402
399
  label = as == :select ? :option : :label
403
- output_buffer.should have_tag("form li.#{as} #{label}", /#{value}/i)
404
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value.to_s}']")
400
+ expect(output_buffer).to have_tag("form li.#{as} #{label}", :text => /#{value}/i)
401
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{value.to_s}']")
405
402
  end
406
403
  end
407
404
  end
@@ -417,8 +414,8 @@ module CustomMacros
417
414
  end)
418
415
 
419
416
  @categories.each do |label, value|
420
- output_buffer.should have_tag("form li.#{as}", /#{label}/)
421
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{value}']")
417
+ expect(output_buffer).to have_tag("form li.#{as}", :text => /#{label}/)
418
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{value}']")
422
419
  end
423
420
  end
424
421
 
@@ -437,7 +434,7 @@ module CustomMacros
437
434
 
438
435
  it 'should have options with text content from the specified method' do
439
436
  ::Author.all.each do |author|
440
- output_buffer.should have_tag("form li.#{as}", /#{author.login}/)
437
+ expect(output_buffer).to have_tag("form li.#{as}", :text => /#{author.login}/)
441
438
  end
442
439
  end
443
440
  end
@@ -453,7 +450,7 @@ module CustomMacros
453
450
 
454
451
  it 'should have options with the proc applied to each' do
455
452
  ::Author.all.each do |author|
456
- output_buffer.should have_tag("form li.#{as}", /#{author.login.reverse}/)
453
+ expect(output_buffer).to have_tag("form li.#{as}", :text => /#{author.login.reverse}/)
457
454
  end
458
455
  end
459
456
  end
@@ -472,7 +469,7 @@ module CustomMacros
472
469
 
473
470
  it 'should have options with the proc applied to each' do
474
471
  ::Author.all.each do |author|
475
- output_buffer.should have_tag("form li.#{as}", /#{author.login.reverse}/)
472
+ expect(output_buffer).to have_tag("form li.#{as}", :text => /#{author.login.reverse}/)
476
473
  end
477
474
  end
478
475
  end
@@ -483,8 +480,8 @@ module CustomMacros
483
480
 
484
481
  describe "when the collection objects respond to #{label_method}" do
485
482
  before do
486
- @fred.stub(:respond_to?) { |m| m.to_s == label_method || m.to_s == 'id' }
487
- [@fred, @bob].each { |a| a.stub(label_method).and_return('The Label Text') }
483
+ allow(@fred).to receive(:respond_to?) { |m| m.to_s == label_method || m.to_s == 'id' }
484
+ [@fred, @bob].each { |a| allow(a).to receive(label_method).and_return('The Label Text') }
488
485
 
489
486
  with_deprecation_silenced do
490
487
  concat(semantic_form_for(@new_post) do |builder|
@@ -495,7 +492,7 @@ module CustomMacros
495
492
 
496
493
  it "should render the options with #{label_method} as the label" do
497
494
  ::Author.all.each do |author|
498
- output_buffer.should have_tag("form li.#{as}", /The Label Text/)
495
+ expect(output_buffer).to have_tag("form li.#{as}", :text => /The Label Text/)
499
496
  end
500
497
  end
501
498
  end
@@ -516,7 +513,7 @@ module CustomMacros
516
513
 
517
514
  it 'should have options with values from specified method' do
518
515
  ::Author.all.each do |author|
519
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login}']")
516
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{author.login}']")
520
517
  end
521
518
  end
522
519
  end
@@ -532,7 +529,7 @@ module CustomMacros
532
529
 
533
530
  it 'should have options with the proc applied to each value' do
534
531
  ::Author.all.each do |author|
535
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
532
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
536
533
  end
537
534
  end
538
535
  end
@@ -551,7 +548,7 @@ module CustomMacros
551
548
 
552
549
  it 'should have options with the proc applied to each value' do
553
550
  ::Author.all.each do |author|
554
- output_buffer.should have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
551
+ expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
555
552
  end
556
553
  end
557
554
  end