formtastic 3.1.5 → 4.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitattributes +1 -0
- data/.gitignore +3 -2
- data/.travis.yml +28 -40
- data/CHANGELOG.md +49 -0
- data/DEPRECATIONS +1 -1
- data/Gemfile.lock +104 -0
- data/README.md +628 -629
- data/Rakefile +20 -1
- data/app/assets/stylesheets/formtastic.css +1 -1
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +8 -14
- data/gemfiles/rails_5.2/Gemfile +5 -0
- data/gemfiles/rails_6.0/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +13 -0
- data/lib/formtastic.rb +5 -11
- data/lib/formtastic/actions.rb +6 -3
- data/lib/formtastic/deprecation.rb +1 -38
- data/lib/formtastic/engine.rb +3 -1
- data/lib/formtastic/form_builder.rb +8 -24
- data/lib/formtastic/helpers/action_helper.rb +1 -48
- data/lib/formtastic/helpers/errors_helper.rb +2 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +7 -3
- data/lib/formtastic/helpers/input_helper.rb +18 -76
- data/lib/formtastic/helpers/inputs_helper.rb +12 -3
- data/lib/formtastic/i18n.rb +1 -1
- data/lib/formtastic/inputs.rb +32 -29
- data/lib/formtastic/inputs/base/collections.rb +1 -5
- data/lib/formtastic/inputs/base/errors.rb +4 -4
- data/lib/formtastic/inputs/base/hints.rb +1 -1
- data/lib/formtastic/inputs/base/timeish.rb +5 -1
- data/lib/formtastic/inputs/base/validations.rb +19 -9
- data/lib/formtastic/inputs/check_boxes_input.rb +3 -3
- data/lib/formtastic/inputs/color_input.rb +0 -1
- data/lib/formtastic/inputs/select_input.rb +1 -1
- data/lib/formtastic/localizer.rb +5 -7
- data/lib/formtastic/version.rb +1 -1
- data/lib/generators/templates/formtastic.rb +4 -6
- data/script/integration-template.rb +71 -0
- data/script/integration.sh +19 -0
- data/spec/action_class_finder_spec.rb +1 -1
- data/spec/actions/button_action_spec.rb +8 -8
- data/spec/actions/generic_action_spec.rb +60 -60
- data/spec/actions/input_action_spec.rb +7 -7
- data/spec/actions/link_action_spec.rb +10 -10
- data/spec/builder/custom_builder_spec.rb +36 -20
- data/spec/builder/error_proc_spec.rb +4 -4
- data/spec/builder/semantic_fields_for_spec.rb +27 -27
- data/spec/generators/formtastic/form/form_generator_spec.rb +25 -25
- data/spec/generators/formtastic/input/input_generator_spec.rb +31 -31
- data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
- data/spec/helpers/action_helper_spec.rb +328 -10
- data/spec/helpers/actions_helper_spec.rb +17 -17
- data/spec/helpers/form_helper_spec.rb +33 -33
- data/spec/helpers/input_helper_spec.rb +975 -2
- data/spec/helpers/inputs_helper_spec.rb +120 -105
- data/spec/helpers/reflection_helper_spec.rb +3 -3
- data/spec/helpers/semantic_errors_helper_spec.rb +22 -22
- data/spec/i18n_spec.rb +26 -26
- data/spec/input_class_finder_spec.rb +1 -1
- data/spec/inputs/base/collections_spec.rb +6 -6
- data/spec/inputs/base/validations_spec.rb +157 -19
- data/spec/inputs/boolean_input_spec.rb +55 -55
- data/spec/inputs/check_boxes_input_spec.rb +96 -95
- data/spec/inputs/color_input_spec.rb +51 -63
- data/spec/inputs/country_input_spec.rb +20 -20
- data/spec/inputs/custom_input_spec.rb +2 -6
- data/spec/inputs/datalist_input_spec.rb +1 -1
- data/spec/inputs/date_picker_input_spec.rb +42 -42
- data/spec/inputs/date_select_input_spec.rb +51 -37
- data/spec/inputs/datetime_picker_input_spec.rb +46 -46
- data/spec/inputs/datetime_select_input_spec.rb +53 -37
- data/spec/inputs/email_input_spec.rb +5 -5
- data/spec/inputs/file_input_spec.rb +6 -6
- data/spec/inputs/hidden_input_spec.rb +18 -18
- data/spec/inputs/include_blank_spec.rb +8 -8
- data/spec/inputs/label_spec.rb +20 -20
- data/spec/inputs/number_input_spec.rb +112 -112
- data/spec/inputs/password_input_spec.rb +5 -5
- data/spec/inputs/phone_input_spec.rb +5 -5
- data/spec/inputs/placeholder_spec.rb +5 -5
- data/spec/inputs/radio_input_spec.rb +63 -65
- data/spec/inputs/range_input_spec.rb +66 -66
- data/spec/inputs/readonly_spec.rb +4 -4
- data/spec/inputs/search_input_spec.rb +5 -5
- data/spec/inputs/select_input_spec.rb +92 -96
- data/spec/inputs/string_input_spec.rb +23 -23
- data/spec/inputs/text_input_spec.rb +16 -16
- data/spec/inputs/time_picker_input_spec.rb +43 -43
- data/spec/inputs/time_select_input_spec.rb +67 -54
- data/spec/inputs/time_zone_input_spec.rb +19 -19
- data/spec/inputs/url_input_spec.rb +5 -5
- data/spec/inputs/with_options_spec.rb +7 -7
- data/spec/localizer_spec.rb +17 -17
- data/spec/namespaced_class_finder_spec.rb +2 -2
- data/spec/schema.rb +21 -0
- data/spec/spec_helper.rb +163 -223
- data/spec/support/custom_macros.rb +72 -75
- data/spec/support/shared_examples.rb +0 -1301
- data/spec/support/test_environment.rb +23 -9
- metadata +33 -123
- data/Appraisals +0 -43
- data/CHANGELOG +0 -54
- data/gemfiles/rails_3.2.gemfile +0 -9
- data/gemfiles/rails_4.0.4.gemfile +0 -8
- data/gemfiles/rails_4.1.gemfile +0 -8
- data/gemfiles/rails_4.2.gemfile +0 -8
- data/gemfiles/rails_4.gemfile +0 -8
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_edge.gemfile +0 -15
- data/lib/formtastic/util.rb +0 -57
- data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
- data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
- 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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
128
|
-
output_buffer.
|
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.
|
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.
|
150
|
-
output_buffer.
|
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.
|
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.
|
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.
|
176
|
-
output_buffer.
|
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.
|
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.
|
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.
|
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.
|
201
|
+
allow(@errors).to receive(:[]).with(errors_matcher("title_#{suffix}".to_sym)).and_return(nil)
|
201
202
|
end
|
202
|
-
@new_post.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
-
|
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.
|
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.
|
317
|
-
output_buffer.
|
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.
|
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.
|
331
|
-
output_buffer.
|
332
|
-
output_buffer.
|
333
|
-
output_buffer.
|
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.
|
350
|
-
output_buffer.
|
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.
|
368
|
-
output_buffer.
|
369
|
-
output_buffer.
|
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.
|
386
|
-
output_buffer.
|
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.
|
404
|
-
output_buffer.
|
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.
|
421
|
-
output_buffer.
|
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.
|
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.
|
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.
|
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.
|
487
|
-
[@fred, @bob].each { |a| a.
|
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.
|
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.
|
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.
|
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.
|
551
|
+
expect(output_buffer).to have_tag("form li.#{as} #{countable}[@value='#{author.login.reverse}']")
|
555
552
|
end
|
556
553
|
end
|
557
554
|
end
|