formtastic 4.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +13 -13
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +99 -64
- data/README.md +7 -2
- data/formtastic.gemspec +5 -3
- data/gemfiles/{rails_5.2 → rails_7.0}/Gemfile +1 -1
- data/gemfiles/rails_7.1/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +1 -1
- data/lib/formtastic/action_class_finder.rb +1 -0
- data/lib/formtastic/actions/base.rb +1 -0
- data/lib/formtastic/actions/button_action.rb +1 -0
- data/lib/formtastic/actions/buttonish.rb +1 -0
- data/lib/formtastic/actions/input_action.rb +1 -0
- data/lib/formtastic/actions/link_action.rb +1 -0
- data/lib/formtastic/actions.rb +1 -0
- data/lib/formtastic/deprecation.rb +2 -1
- data/lib/formtastic/engine.rb +1 -0
- data/lib/formtastic/form_builder.rb +1 -0
- data/lib/formtastic/helpers/action_helper.rb +1 -0
- data/lib/formtastic/helpers/actions_helper.rb +1 -0
- data/lib/formtastic/helpers/enum.rb +1 -0
- data/lib/formtastic/helpers/errors_helper.rb +1 -0
- data/lib/formtastic/helpers/fieldset_wrapper.rb +1 -0
- data/lib/formtastic/helpers/file_column_detection.rb +1 -0
- data/lib/formtastic/helpers/form_helper.rb +1 -0
- data/lib/formtastic/helpers/input_helper.rb +2 -4
- data/lib/formtastic/helpers/inputs_helper.rb +2 -1
- data/lib/formtastic/helpers/reflection.rb +1 -0
- data/lib/formtastic/helpers.rb +1 -1
- data/lib/formtastic/html_attributes.rb +1 -0
- data/lib/formtastic/i18n.rb +1 -0
- data/lib/formtastic/input_class_finder.rb +1 -0
- data/lib/formtastic/inputs/base/associations.rb +1 -0
- data/lib/formtastic/inputs/base/choices.rb +2 -1
- data/lib/formtastic/inputs/base/collections.rb +4 -1
- data/lib/formtastic/inputs/base/database.rb +5 -7
- data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
- data/lib/formtastic/inputs/base/errors.rb +3 -2
- data/lib/formtastic/inputs/base/fileish.rb +1 -0
- data/lib/formtastic/inputs/base/hints.rb +1 -0
- data/lib/formtastic/inputs/base/html.rb +2 -1
- data/lib/formtastic/inputs/base/labelling.rb +3 -2
- data/lib/formtastic/inputs/base/naming.rb +1 -0
- data/lib/formtastic/inputs/base/numeric.rb +1 -0
- data/lib/formtastic/inputs/base/options.rb +1 -0
- data/lib/formtastic/inputs/base/placeholder.rb +1 -0
- data/lib/formtastic/inputs/base/stringish.rb +1 -0
- data/lib/formtastic/inputs/base/timeish.rb +4 -3
- data/lib/formtastic/inputs/base/validations.rb +2 -1
- data/lib/formtastic/inputs/base/wrapping.rb +1 -0
- data/lib/formtastic/inputs/base.rb +3 -2
- data/lib/formtastic/inputs/boolean_input.rb +2 -1
- data/lib/formtastic/inputs/check_boxes_input.rb +2 -1
- data/lib/formtastic/inputs/color_input.rb +1 -0
- data/lib/formtastic/inputs/country_input.rb +1 -0
- data/lib/formtastic/inputs/datalist_input.rb +1 -0
- data/lib/formtastic/inputs/date_picker_input.rb +1 -0
- data/lib/formtastic/inputs/date_select_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
- data/lib/formtastic/inputs/email_input.rb +1 -0
- data/lib/formtastic/inputs/file_input.rb +1 -0
- data/lib/formtastic/inputs/hidden_input.rb +3 -2
- data/lib/formtastic/inputs/number_input.rb +1 -0
- data/lib/formtastic/inputs/password_input.rb +1 -0
- data/lib/formtastic/inputs/phone_input.rb +1 -0
- data/lib/formtastic/inputs/radio_input.rb +1 -0
- data/lib/formtastic/inputs/range_input.rb +1 -0
- data/lib/formtastic/inputs/search_input.rb +1 -0
- data/lib/formtastic/inputs/select_input.rb +1 -0
- data/lib/formtastic/inputs/string_input.rb +1 -0
- data/lib/formtastic/inputs/text_input.rb +1 -0
- data/lib/formtastic/inputs/time_picker_input.rb +1 -0
- data/lib/formtastic/inputs/time_select_input.rb +1 -0
- data/lib/formtastic/inputs/time_zone_input.rb +1 -0
- data/lib/formtastic/inputs/url_input.rb +1 -0
- data/lib/formtastic/inputs.rb +1 -0
- data/lib/formtastic/localized_string.rb +1 -0
- data/lib/formtastic/localizer.rb +1 -0
- data/lib/formtastic/namespaced_class_finder.rb +7 -8
- data/lib/formtastic/version.rb +2 -1
- data/lib/formtastic.rb +1 -0
- data/lib/generators/formtastic/form/form_generator.rb +1 -0
- data/lib/generators/formtastic/input/input_generator.rb +1 -0
- data/lib/generators/formtastic/install/install_generator.rb +1 -0
- data/lib/generators/templates/formtastic.rb +1 -0
- data/script/integration-template.rb +2 -3
- data/spec/action_class_finder_spec.rb +1 -0
- data/spec/actions/button_action_spec.rb +17 -16
- data/spec/actions/generic_action_spec.rb +130 -129
- data/spec/actions/input_action_spec.rb +16 -15
- data/spec/actions/link_action_spec.rb +25 -24
- data/spec/builder/custom_builder_spec.rb +5 -4
- data/spec/builder/error_proc_spec.rb +2 -1
- data/spec/builder/semantic_fields_for_spec.rb +26 -25
- data/spec/fast_spec_helper.rb +1 -0
- data/spec/generators/formtastic/form/form_generator_spec.rb +8 -7
- data/spec/generators/formtastic/input/input_generator_spec.rb +1 -0
- data/spec/generators/formtastic/install/install_generator_spec.rb +1 -0
- data/spec/helpers/action_helper_spec.rb +15 -14
- data/spec/helpers/actions_helper_spec.rb +42 -41
- data/spec/helpers/form_helper_spec.rb +26 -19
- data/spec/helpers/input_helper_spec.rb +70 -69
- data/spec/helpers/inputs_helper_spec.rb +179 -179
- data/spec/helpers/reflection_helper_spec.rb +4 -3
- data/spec/helpers/semantic_errors_helper_spec.rb +4 -3
- data/spec/i18n_spec.rb +13 -12
- data/spec/input_class_finder_spec.rb +1 -0
- data/spec/inputs/base/collections_spec.rb +2 -0
- data/spec/inputs/base/validations_spec.rb +1 -0
- data/spec/inputs/boolean_input_spec.rb +66 -65
- data/spec/inputs/check_boxes_input_spec.rb +89 -88
- data/spec/inputs/color_input_spec.rb +7 -6
- data/spec/inputs/country_input_spec.rb +10 -9
- data/spec/inputs/custom_input_spec.rb +1 -0
- data/spec/inputs/datalist_input_spec.rb +2 -1
- data/spec/inputs/date_picker_input_spec.rb +109 -108
- data/spec/inputs/date_select_input_spec.rb +63 -62
- data/spec/inputs/datetime_picker_input_spec.rb +118 -117
- data/spec/inputs/datetime_select_input_spec.rb +72 -71
- data/spec/inputs/email_input_spec.rb +16 -15
- data/spec/inputs/file_input_spec.rb +17 -16
- data/spec/inputs/hidden_input_spec.rb +29 -28
- data/spec/inputs/include_blank_spec.rb +7 -6
- data/spec/inputs/label_spec.rb +25 -24
- data/spec/inputs/number_input_spec.rb +159 -158
- data/spec/inputs/password_input_spec.rb +16 -15
- data/spec/inputs/phone_input_spec.rb +16 -15
- data/spec/inputs/placeholder_spec.rb +17 -16
- data/spec/inputs/radio_input_spec.rb +58 -57
- data/spec/inputs/range_input_spec.rb +108 -107
- data/spec/inputs/readonly_spec.rb +5 -4
- data/spec/inputs/search_input_spec.rb +15 -14
- data/spec/inputs/select_input_spec.rb +144 -93
- data/spec/inputs/string_input_spec.rb +36 -35
- data/spec/inputs/text_input_spec.rb +32 -31
- data/spec/inputs/time_picker_input_spec.rb +110 -109
- data/spec/inputs/time_select_input_spec.rb +71 -70
- data/spec/inputs/time_zone_input_spec.rb +21 -20
- data/spec/inputs/url_input_spec.rb +16 -15
- data/spec/inputs/with_options_spec.rb +8 -7
- data/spec/localizer_spec.rb +1 -0
- data/spec/namespaced_class_finder_spec.rb +17 -5
- data/spec/schema.rb +1 -0
- data/spec/spec_helper.rb +8 -8
- data/spec/support/custom_macros.rb +64 -63
- data/spec/support/deprecation.rb +2 -1
- data/spec/support/shared_examples.rb +2 -1
- data/spec/support/specialized_class_finder_shared_example.rb +1 -0
- data/spec/support/test_environment.rb +1 -0
- metadata +29 -14
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
RSpec.describe 'string input' do
|
@@ -6,7 +7,7 @@ RSpec.describe 'string input' do
|
|
6
7
|
include FormtasticSpecHelper
|
7
8
|
|
8
9
|
before do
|
9
|
-
@output_buffer = ''
|
10
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
10
11
|
mock_everything
|
11
12
|
end
|
12
13
|
|
@@ -16,7 +17,7 @@ RSpec.describe 'string input' do
|
|
16
17
|
concat(builder.input(:title, :as => :string))
|
17
18
|
end)
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
it_should_have_input_wrapper_with_class(:string)
|
21
22
|
it_should_have_input_wrapper_with_class(:input)
|
22
23
|
it_should_have_input_wrapper_with_class(:stringish)
|
@@ -32,12 +33,12 @@ RSpec.describe 'string input' do
|
|
32
33
|
it_should_apply_custom_input_attributes_when_input_html_provided(:string)
|
33
34
|
it_should_apply_custom_for_to_label_when_input_html_id_provided(:string)
|
34
35
|
it_should_apply_error_logic_for_input_type(:string)
|
35
|
-
|
36
|
+
|
36
37
|
def input_field_for_method_should_have_maxlength(method, maxlength)
|
37
38
|
concat(semantic_form_for(@new_post) do |builder|
|
38
39
|
concat(builder.input(method))
|
39
40
|
end)
|
40
|
-
expect(output_buffer).to have_tag("form li input[@maxlength='#{maxlength}']")
|
41
|
+
expect(output_buffer.to_str).to have_tag("form li input[@maxlength='#{maxlength}']")
|
41
42
|
end
|
42
43
|
|
43
44
|
describe 'and its a ActiveModel' do
|
@@ -61,30 +62,30 @@ RSpec.describe 'string input' do
|
|
61
62
|
concat(builder.input(:title))
|
62
63
|
end)
|
63
64
|
|
64
|
-
expect(output_buffer).to have_tag("form li input##{@new_post.class.name.underscore}_title[@maxlength='#{maxlength}']")
|
65
|
+
expect(output_buffer.to_str).to have_tag("form li input##{@new_post.class.name.underscore}_title[@maxlength='#{maxlength}']")
|
65
66
|
end
|
66
67
|
|
67
68
|
it 'should have maxlength if the optional :if or :unless options are not supplied' do
|
68
69
|
should_have_maxlength(42, :options => {:maximum => 42})
|
69
70
|
end
|
70
|
-
|
71
|
+
|
71
72
|
it 'should have default maxlength if the optional :if condition is not satisifed' do
|
72
73
|
should_have_maxlength(default_maxlength, :options => {:maximum => 42, :if => false})
|
73
74
|
end
|
74
|
-
|
75
|
+
|
75
76
|
it 'should have default_maxlength if the optional :if proc evaluates to false' do
|
76
77
|
should_have_maxlength(default_maxlength, :options => {:maximum => 42, :if => proc { |record| false }})
|
77
78
|
end
|
78
|
-
|
79
|
+
|
79
80
|
it 'should have maxlength if the optional :if proc evaluates to true' do
|
80
81
|
should_have_maxlength(42, :options => { :maximum => 42, :if => proc { |record| true } })
|
81
82
|
end
|
82
|
-
|
83
|
+
|
83
84
|
it 'should have default maxlength if the optional :if with a method name evaluates to false' do
|
84
85
|
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(false)
|
85
86
|
should_have_maxlength(default_maxlength, :options => { :maximum => 42, :if => :specify_maxlength })
|
86
87
|
end
|
87
|
-
|
88
|
+
|
88
89
|
it 'should have maxlength if the optional :if with a method name evaluates to true' do
|
89
90
|
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(true)
|
90
91
|
should_have_maxlength(42, :options => { :maximum => 42, :if => :specify_maxlength })
|
@@ -97,12 +98,12 @@ RSpec.describe 'string input' do
|
|
97
98
|
it 'should have maxlength if the optional :unless proc evaluates to false' do
|
98
99
|
should_have_maxlength(42, :options => { :maximum => 42, :unless => proc { |record| false } })
|
99
100
|
end
|
100
|
-
|
101
|
+
|
101
102
|
it 'should have default maxlength if the optional :unless with a method name evaluates to true' do
|
102
103
|
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(true)
|
103
104
|
should_have_maxlength(default_maxlength, :options => { :maximum => 42, :unless => :specify_maxlength })
|
104
105
|
end
|
105
|
-
|
106
|
+
|
106
107
|
it 'should have maxlength if the optional :unless with a method name evaluates to false' do
|
107
108
|
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(false)
|
108
109
|
should_have_maxlength(42, :options => { :maximum => 42, :unless => :specify_maxlength })
|
@@ -164,22 +165,22 @@ RSpec.describe 'string input' do
|
|
164
165
|
end
|
165
166
|
|
166
167
|
describe "when namespace is provided" do
|
167
|
-
|
168
|
+
|
168
169
|
before do
|
169
170
|
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
170
171
|
concat(builder.input(:title, :as => :string))
|
171
172
|
end)
|
172
173
|
end
|
173
|
-
|
174
|
+
|
174
175
|
it_should_have_input_wrapper_with_id("context2_post_title_input")
|
175
176
|
it_should_have_label_and_input_with_id("context2_post_title")
|
176
|
-
|
177
|
+
|
177
178
|
end
|
178
|
-
|
179
|
+
|
179
180
|
describe "when index is provided" do
|
180
181
|
|
181
182
|
before do
|
182
|
-
@output_buffer = ''
|
183
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
183
184
|
mock_everything
|
184
185
|
|
185
186
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -188,57 +189,57 @@ RSpec.describe 'string input' do
|
|
188
189
|
end)
|
189
190
|
end)
|
190
191
|
end
|
191
|
-
|
192
|
+
|
192
193
|
it 'should index the id of the wrapper' do
|
193
|
-
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
194
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
194
195
|
end
|
195
|
-
|
196
|
+
|
196
197
|
it 'should index the id of the select tag' do
|
197
|
-
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
198
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_name")
|
198
199
|
end
|
199
|
-
|
200
|
+
|
200
201
|
it 'should index the name of the select tag' do
|
201
|
-
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
202
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][name]']")
|
202
203
|
end
|
203
|
-
|
204
|
+
|
204
205
|
end
|
205
|
-
|
206
|
-
|
206
|
+
|
207
|
+
|
207
208
|
describe "when no object is provided" do
|
208
209
|
before do
|
209
210
|
concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
|
210
211
|
concat(builder.input(:title, :as => :string))
|
211
212
|
end)
|
212
213
|
end
|
213
|
-
|
214
|
+
|
214
215
|
it_should_have_label_with_text(/Title/)
|
215
216
|
it_should_have_label_for("project_title")
|
216
217
|
it_should_have_input_with_id("project_title")
|
217
218
|
it_should_have_input_with_type(:text)
|
218
219
|
it_should_have_input_with_name("project[title]")
|
219
220
|
end
|
220
|
-
|
221
|
+
|
221
222
|
describe "when size is nil" do
|
222
223
|
before do
|
223
224
|
concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
|
224
225
|
concat(builder.input(:title, :as => :string, :input_html => {:size => nil}))
|
225
226
|
end)
|
226
227
|
end
|
227
|
-
|
228
|
+
|
228
229
|
it "should have no size attribute" do
|
229
|
-
expect(output_buffer).not_to have_tag("input[@size]")
|
230
|
+
expect(output_buffer.to_str).not_to have_tag("input[@size]")
|
230
231
|
end
|
231
232
|
end
|
232
|
-
|
233
|
+
|
233
234
|
describe "when required" do
|
234
|
-
|
235
|
+
|
235
236
|
context "and configured to use HTML5 attribute" do
|
236
237
|
it "should add the required attribute to the input's html options" do
|
237
238
|
with_config :use_required_attribute, true do
|
238
239
|
concat(semantic_form_for(@new_post) do |builder|
|
239
240
|
concat(builder.input(:title, :as => :string, :required => true))
|
240
241
|
end)
|
241
|
-
expect(output_buffer).to have_tag("input[@required]")
|
242
|
+
expect(output_buffer.to_str).to have_tag("input[@required]")
|
242
243
|
end
|
243
244
|
end
|
244
245
|
end
|
@@ -249,11 +250,11 @@ RSpec.describe 'string input' do
|
|
249
250
|
concat(semantic_form_for(@new_post) do |builder|
|
250
251
|
concat(builder.input(:title, :as => :string, :required => true))
|
251
252
|
end)
|
252
|
-
expect(output_buffer).not_to have_tag("input[@required]")
|
253
|
+
expect(output_buffer.to_str).not_to have_tag("input[@required]")
|
253
254
|
end
|
254
255
|
end
|
255
256
|
end
|
256
|
-
|
257
|
+
|
257
258
|
end
|
258
259
|
|
259
260
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
RSpec.describe 'text input' do
|
@@ -6,7 +7,7 @@ RSpec.describe 'text input' do
|
|
6
7
|
include FormtasticSpecHelper
|
7
8
|
|
8
9
|
before do
|
9
|
-
@output_buffer = ''
|
10
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
10
11
|
mock_everything
|
11
12
|
|
12
13
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -24,50 +25,50 @@ RSpec.describe 'text input' do
|
|
24
25
|
it_should_apply_error_logic_for_input_type(:number)
|
25
26
|
|
26
27
|
it 'should use input_html to style inputs' do
|
27
|
-
output_buffer.
|
28
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
28
29
|
concat(semantic_form_for(@new_post) do |builder|
|
29
30
|
concat(builder.input(:title, :as => :text, :input_html => { :class => 'myclass' }))
|
30
31
|
end)
|
31
|
-
expect(output_buffer).to have_tag("form li textarea.myclass")
|
32
|
+
expect(output_buffer.to_str).to have_tag("form li textarea.myclass")
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should have a cols attribute when :cols is a number in :input_html" do
|
35
|
-
output_buffer.
|
36
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
36
37
|
concat(semantic_form_for(@new_post) do |builder|
|
37
38
|
concat(builder.input(:title, :as => :text, :input_html => { :cols => 42 }))
|
38
39
|
end)
|
39
|
-
expect(output_buffer).to have_tag("form li textarea[@cols='42']")
|
40
|
+
expect(output_buffer.to_str).to have_tag("form li textarea[@cols='42']")
|
40
41
|
end
|
41
42
|
|
42
43
|
it "should not have a cols attribute when :cols is nil in :input_html" do
|
43
|
-
output_buffer.
|
44
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
44
45
|
concat(semantic_form_for(@new_post) do |builder|
|
45
46
|
concat(builder.input(:title, :as => :text, :input_html => { :cols => nil }))
|
46
47
|
end)
|
47
|
-
expect(output_buffer).not_to have_tag("form li textarea[@cols]")
|
48
|
+
expect(output_buffer.to_str).not_to have_tag("form li textarea[@cols]")
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should have a rows attribute when :rows is a number in :input_html" do
|
51
|
-
output_buffer.
|
52
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
52
53
|
concat(semantic_form_for(@new_post) do |builder|
|
53
54
|
concat(builder.input(:title, :as => :text, :input_html => { :rows => 42 }))
|
54
55
|
end)
|
55
|
-
expect(output_buffer).to have_tag("form li textarea[@rows='42']")
|
56
|
+
expect(output_buffer.to_str).to have_tag("form li textarea[@rows='42']")
|
56
57
|
|
57
58
|
end
|
58
59
|
|
59
60
|
it "should not have a rows attribute when :rows is nil in :input_html" do
|
60
|
-
output_buffer.
|
61
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
61
62
|
concat(semantic_form_for(@new_post) do |builder|
|
62
63
|
concat(builder.input(:title, :as => :text, :input_html => { :rows => nil }))
|
63
64
|
end)
|
64
|
-
expect(output_buffer).not_to have_tag("form li textarea[@rows]")
|
65
|
+
expect(output_buffer.to_str).not_to have_tag("form li textarea[@rows]")
|
65
66
|
end
|
66
67
|
|
67
68
|
describe "when namespace is provided" do
|
68
69
|
|
69
70
|
before do
|
70
|
-
@output_buffer = ''
|
71
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
71
72
|
mock_everything
|
72
73
|
|
73
74
|
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
@@ -80,11 +81,11 @@ RSpec.describe 'text input' do
|
|
80
81
|
it_should_have_label_for("context2_post_body")
|
81
82
|
|
82
83
|
end
|
83
|
-
|
84
|
+
|
84
85
|
describe "when index is provided" do
|
85
86
|
|
86
87
|
before do
|
87
|
-
@output_buffer = ''
|
88
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
88
89
|
mock_everything
|
89
90
|
|
90
91
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -93,28 +94,28 @@ RSpec.describe 'text input' do
|
|
93
94
|
end)
|
94
95
|
end)
|
95
96
|
end
|
96
|
-
|
97
|
+
|
97
98
|
it 'should index the id of the wrapper' do
|
98
|
-
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
99
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
99
100
|
end
|
100
|
-
|
101
|
+
|
101
102
|
it 'should index the id of the select tag' do
|
102
|
-
expect(output_buffer).to have_tag("textarea#post_author_attributes_3_name")
|
103
|
+
expect(output_buffer.to_str).to have_tag("textarea#post_author_attributes_3_name")
|
103
104
|
end
|
104
|
-
|
105
|
+
|
105
106
|
it 'should index the name of the select tag' do
|
106
|
-
expect(output_buffer).to have_tag("textarea[@name='post[author_attributes][3][name]']")
|
107
|
+
expect(output_buffer.to_str).to have_tag("textarea[@name='post[author_attributes][3][name]']")
|
107
108
|
end
|
108
|
-
|
109
|
+
|
109
110
|
end
|
110
|
-
|
111
|
+
|
111
112
|
context "when required" do
|
112
113
|
it "should add the required attribute to the input's html options" do
|
113
|
-
with_config :use_required_attribute, true do
|
114
|
+
with_config :use_required_attribute, true do
|
114
115
|
concat(semantic_form_for(@new_post) do |builder|
|
115
116
|
concat(builder.input(:title, :as => :text, :required => true))
|
116
117
|
end)
|
117
|
-
expect(output_buffer).to have_tag("textarea[@required]")
|
118
|
+
expect(output_buffer.to_str).to have_tag("textarea[@required]")
|
118
119
|
end
|
119
120
|
end
|
120
121
|
end
|
@@ -129,13 +130,13 @@ RSpec.describe 'text input' do
|
|
129
130
|
it_should_have_input_wrapper_with_class("autofocus")
|
130
131
|
|
131
132
|
it "should add the autofocus attribute to the input's html options" do
|
132
|
-
expect(output_buffer).to have_tag("input[@autofocus]")
|
133
|
+
expect(output_buffer.to_str).to have_tag("input[@autofocus]")
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
136
137
|
context "when :rows is missing in :input_html" do
|
137
138
|
before do
|
138
|
-
output_buffer.
|
139
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
139
140
|
end
|
140
141
|
|
141
142
|
it "should have a rows attribute matching default_text_area_height if numeric" do
|
@@ -143,7 +144,7 @@ RSpec.describe 'text input' do
|
|
143
144
|
concat(semantic_form_for(@new_post) do |builder|
|
144
145
|
concat(builder.input(:title, :as => :text))
|
145
146
|
end)
|
146
|
-
expect(output_buffer).to have_tag("form li textarea[@rows='12']")
|
147
|
+
expect(output_buffer.to_str).to have_tag("form li textarea[@rows='12']")
|
147
148
|
end
|
148
149
|
end
|
149
150
|
|
@@ -152,7 +153,7 @@ RSpec.describe 'text input' do
|
|
152
153
|
concat(semantic_form_for(@new_post) do |builder|
|
153
154
|
concat(builder.input(:title, :as => :text))
|
154
155
|
end)
|
155
|
-
expect(output_buffer).not_to have_tag("form li textarea[@rows]")
|
156
|
+
expect(output_buffer.to_str).not_to have_tag("form li textarea[@rows]")
|
156
157
|
end
|
157
158
|
|
158
159
|
end
|
@@ -160,7 +161,7 @@ RSpec.describe 'text input' do
|
|
160
161
|
|
161
162
|
context "when :cols is missing in :input_html" do
|
162
163
|
before do
|
163
|
-
output_buffer.
|
164
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
164
165
|
end
|
165
166
|
|
166
167
|
it "should have a cols attribute matching default_text_area_width if numeric" do
|
@@ -168,7 +169,7 @@ RSpec.describe 'text input' do
|
|
168
169
|
concat(semantic_form_for(@new_post) do |builder|
|
169
170
|
concat(builder.input(:title, :as => :text))
|
170
171
|
end)
|
171
|
-
expect(output_buffer).to have_tag("form li textarea[@cols='10']")
|
172
|
+
expect(output_buffer.to_str).to have_tag("form li textarea[@cols='10']")
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
@@ -177,7 +178,7 @@ RSpec.describe 'text input' do
|
|
177
178
|
concat(semantic_form_for(@new_post) do |builder|
|
178
179
|
concat(builder.input(:title, :as => :text))
|
179
180
|
end)
|
180
|
-
expect(output_buffer).not_to have_tag("form li textarea[@cols]")
|
181
|
+
expect(output_buffer.to_str).not_to have_tag("form li textarea[@cols]")
|
181
182
|
end
|
182
183
|
|
183
184
|
end
|