formtastic 3.0.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +5 -13
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/test.yml +61 -0
  4. data/.gitignore +3 -2
  5. data/CHANGELOG.md +61 -0
  6. data/Gemfile.lock +140 -0
  7. data/MIT-LICENSE +1 -1
  8. data/{README.textile → README.md} +191 -168
  9. data/RELEASE_PROCESS +3 -1
  10. data/Rakefile +24 -8
  11. data/app/assets/stylesheets/formtastic.css +1 -1
  12. data/bin/appraisal +8 -0
  13. data/formtastic.gemspec +13 -17
  14. data/gemfiles/rails_6.0/Gemfile +5 -0
  15. data/gemfiles/rails_6.1/Gemfile +5 -0
  16. data/gemfiles/rails_7.0/Gemfile +5 -0
  17. data/gemfiles/rails_7.1/Gemfile +5 -0
  18. data/gemfiles/rails_edge/Gemfile +13 -0
  19. data/lib/formtastic/action_class_finder.rb +19 -0
  20. data/lib/formtastic/actions/base.rb +1 -0
  21. data/lib/formtastic/actions/button_action.rb +56 -53
  22. data/lib/formtastic/actions/buttonish.rb +1 -0
  23. data/lib/formtastic/actions/input_action.rb +60 -57
  24. data/lib/formtastic/actions/link_action.rb +69 -67
  25. data/lib/formtastic/actions.rb +7 -3
  26. data/lib/formtastic/deprecation.rb +6 -0
  27. data/lib/formtastic/engine.rb +4 -1
  28. data/lib/formtastic/form_builder.rb +32 -25
  29. data/lib/formtastic/helpers/action_helper.rb +22 -31
  30. data/lib/formtastic/helpers/actions_helper.rb +1 -0
  31. data/lib/formtastic/helpers/enum.rb +14 -0
  32. data/lib/formtastic/helpers/errors_helper.rb +3 -2
  33. data/lib/formtastic/helpers/fieldset_wrapper.rb +16 -11
  34. data/lib/formtastic/helpers/file_column_detection.rb +1 -0
  35. data/lib/formtastic/helpers/form_helper.rb +4 -3
  36. data/lib/formtastic/helpers/input_helper.rb +59 -80
  37. data/lib/formtastic/helpers/inputs_helper.rb +33 -27
  38. data/lib/formtastic/helpers/reflection.rb +5 -4
  39. data/lib/formtastic/helpers.rb +2 -2
  40. data/lib/formtastic/html_attributes.rb +13 -1
  41. data/lib/formtastic/i18n.rb +2 -1
  42. data/lib/formtastic/input_class_finder.rb +19 -0
  43. data/lib/formtastic/inputs/base/associations.rb +1 -0
  44. data/lib/formtastic/inputs/base/choices.rb +4 -3
  45. data/lib/formtastic/inputs/base/collections.rb +47 -11
  46. data/lib/formtastic/inputs/base/database.rb +8 -5
  47. data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
  48. data/lib/formtastic/inputs/base/errors.rb +7 -6
  49. data/lib/formtastic/inputs/base/fileish.rb +1 -0
  50. data/lib/formtastic/inputs/base/hints.rb +2 -1
  51. data/lib/formtastic/inputs/base/html.rb +12 -10
  52. data/lib/formtastic/inputs/base/labelling.rb +3 -2
  53. data/lib/formtastic/inputs/base/naming.rb +5 -4
  54. data/lib/formtastic/inputs/base/numeric.rb +1 -0
  55. data/lib/formtastic/inputs/base/options.rb +3 -3
  56. data/lib/formtastic/inputs/base/placeholder.rb +1 -0
  57. data/lib/formtastic/inputs/base/stringish.rb +1 -0
  58. data/lib/formtastic/inputs/base/timeish.rb +9 -4
  59. data/lib/formtastic/inputs/base/validations.rb +39 -12
  60. data/lib/formtastic/inputs/base/wrapping.rb +2 -3
  61. data/lib/formtastic/inputs/base.rb +17 -12
  62. data/lib/formtastic/inputs/boolean_input.rb +2 -1
  63. data/lib/formtastic/inputs/check_boxes_input.rb +16 -24
  64. data/lib/formtastic/inputs/color_input.rb +1 -1
  65. data/lib/formtastic/inputs/country_input.rb +4 -1
  66. data/lib/formtastic/inputs/datalist_input.rb +42 -0
  67. data/lib/formtastic/inputs/date_picker_input.rb +1 -0
  68. data/lib/formtastic/inputs/date_select_input.rb +1 -0
  69. data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
  70. data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
  71. data/lib/formtastic/inputs/email_input.rb +1 -0
  72. data/lib/formtastic/inputs/file_input.rb +3 -2
  73. data/lib/formtastic/inputs/hidden_input.rb +3 -2
  74. data/lib/formtastic/inputs/number_input.rb +1 -0
  75. data/lib/formtastic/inputs/password_input.rb +1 -0
  76. data/lib/formtastic/inputs/phone_input.rb +1 -0
  77. data/lib/formtastic/inputs/radio_input.rb +26 -21
  78. data/lib/formtastic/inputs/range_input.rb +1 -0
  79. data/lib/formtastic/inputs/search_input.rb +1 -0
  80. data/lib/formtastic/inputs/select_input.rb +32 -10
  81. data/lib/formtastic/inputs/string_input.rb +1 -0
  82. data/lib/formtastic/inputs/text_input.rb +1 -0
  83. data/lib/formtastic/inputs/time_picker_input.rb +1 -0
  84. data/lib/formtastic/inputs/time_select_input.rb +1 -0
  85. data/lib/formtastic/inputs/time_zone_input.rb +17 -6
  86. data/lib/formtastic/inputs/url_input.rb +1 -0
  87. data/lib/formtastic/inputs.rb +33 -28
  88. data/lib/formtastic/localized_string.rb +2 -1
  89. data/lib/formtastic/localizer.rb +23 -24
  90. data/lib/formtastic/namespaced_class_finder.rb +98 -0
  91. data/lib/formtastic/version.rb +2 -1
  92. data/lib/formtastic.rb +19 -14
  93. data/lib/generators/formtastic/form/form_generator.rb +8 -2
  94. data/lib/generators/formtastic/input/input_generator.rb +47 -0
  95. data/lib/generators/formtastic/install/install_generator.rb +2 -0
  96. data/lib/generators/templates/formtastic.rb +29 -7
  97. data/lib/generators/templates/input.rb +19 -0
  98. data/sample/basic_inputs.html +1 -1
  99. data/script/integration-template.rb +73 -0
  100. data/script/integration.sh +19 -0
  101. data/spec/action_class_finder_spec.rb +13 -0
  102. data/spec/actions/button_action_spec.rb +21 -20
  103. data/spec/actions/generic_action_spec.rb +134 -133
  104. data/spec/actions/input_action_spec.rb +20 -19
  105. data/spec/actions/link_action_spec.rb +30 -29
  106. data/spec/builder/custom_builder_spec.rb +39 -22
  107. data/spec/builder/error_proc_spec.rb +6 -5
  108. data/spec/builder/semantic_fields_for_spec.rb +46 -45
  109. data/spec/fast_spec_helper.rb +13 -0
  110. data/spec/generators/formtastic/form/form_generator_spec.rb +33 -32
  111. data/spec/generators/formtastic/input/input_generator_spec.rb +125 -0
  112. data/spec/generators/formtastic/install/install_generator_spec.rb +10 -9
  113. data/spec/helpers/action_helper_spec.rb +70 -97
  114. data/spec/helpers/actions_helper_spec.rb +43 -42
  115. data/spec/helpers/form_helper_spec.rb +56 -39
  116. data/spec/helpers/input_helper_spec.rb +314 -255
  117. data/spec/helpers/inputs_helper_spec.rb +217 -202
  118. data/spec/helpers/reflection_helper_spec.rb +7 -6
  119. data/spec/helpers/semantic_errors_helper_spec.rb +26 -25
  120. data/spec/i18n_spec.rb +30 -29
  121. data/spec/input_class_finder_spec.rb +11 -0
  122. data/spec/inputs/base/collections_spec.rb +78 -0
  123. data/spec/inputs/base/validations_spec.rb +481 -0
  124. data/spec/inputs/boolean_input_spec.rb +73 -72
  125. data/spec/inputs/check_boxes_input_spec.rb +174 -123
  126. data/spec/inputs/color_input_spec.rb +53 -64
  127. data/spec/inputs/country_input_spec.rb +23 -22
  128. data/spec/inputs/custom_input_spec.rb +3 -6
  129. data/spec/inputs/datalist_input_spec.rb +62 -0
  130. data/spec/inputs/date_picker_input_spec.rb +114 -113
  131. data/spec/inputs/date_select_input_spec.rb +76 -61
  132. data/spec/inputs/datetime_picker_input_spec.rb +123 -122
  133. data/spec/inputs/datetime_select_input_spec.rb +85 -68
  134. data/spec/inputs/email_input_spec.rb +17 -16
  135. data/spec/inputs/file_input_spec.rb +18 -17
  136. data/spec/inputs/hidden_input_spec.rb +32 -31
  137. data/spec/inputs/include_blank_spec.rb +10 -9
  138. data/spec/inputs/label_spec.rb +36 -31
  139. data/spec/inputs/number_input_spec.rb +212 -211
  140. data/spec/inputs/password_input_spec.rb +17 -16
  141. data/spec/inputs/phone_input_spec.rb +17 -16
  142. data/spec/inputs/placeholder_spec.rb +18 -17
  143. data/spec/inputs/radio_input_spec.rb +92 -65
  144. data/spec/inputs/range_input_spec.rb +136 -135
  145. data/spec/inputs/readonly_spec.rb +51 -0
  146. data/spec/inputs/search_input_spec.rb +16 -15
  147. data/spec/inputs/select_input_spec.rb +209 -102
  148. data/spec/inputs/string_input_spec.rb +51 -50
  149. data/spec/inputs/text_input_spec.rb +34 -33
  150. data/spec/inputs/time_picker_input_spec.rb +115 -114
  151. data/spec/inputs/time_select_input_spec.rb +84 -70
  152. data/spec/inputs/time_zone_input_spec.rb +58 -31
  153. data/spec/inputs/url_input_spec.rb +17 -16
  154. data/spec/inputs/with_options_spec.rb +9 -8
  155. data/spec/localizer_spec.rb +18 -17
  156. data/spec/namespaced_class_finder_spec.rb +91 -0
  157. data/spec/schema.rb +22 -0
  158. data/spec/spec_helper.rb +180 -249
  159. data/spec/support/custom_macros.rb +128 -98
  160. data/spec/support/deprecation.rb +2 -1
  161. data/spec/support/shared_examples.rb +13 -0
  162. data/spec/support/specialized_class_finder_shared_example.rb +28 -0
  163. data/spec/support/test_environment.rb +25 -10
  164. metadata +95 -136
  165. data/.travis.yml +0 -28
  166. data/Appraisals +0 -25
  167. data/CHANGELOG +0 -27
  168. data/gemfiles/rails_3.2.gemfile +0 -7
  169. data/gemfiles/rails_4.0.4.gemfile +0 -7
  170. data/gemfiles/rails_4.1.gemfile +0 -7
  171. data/gemfiles/rails_4.gemfile +0 -7
  172. data/gemfiles/rails_edge.gemfile +0 -10
  173. data/lib/formtastic/util.rb +0 -53
  174. data/spec/support/deferred_garbage_collection.rb +0 -21
  175. data/spec/util_spec.rb +0 -52
@@ -1,12 +1,13 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'spec_helper'
3
4
 
4
- describe 'string input' do
5
+ RSpec.describe 'string input' do
5
6
 
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 @@ 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,28 +33,28 @@ 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
- output_buffer.should 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
44
45
  let(:default_maxlength) { 50 }
45
46
 
46
47
  before do
47
- @new_post.stub(:class).and_return(::PostModel)
48
+ allow(@new_post).to receive(:class).and_return(::PostModel)
48
49
  end
49
50
 
50
51
  after do
51
- @new_post.stub(:class).and_return(::Post)
52
+ allow(@new_post).to receive(:class).and_return(::Post)
52
53
  end
53
54
 
54
55
  describe 'and validates_length_of was called for the method' do
55
56
  def should_have_maxlength(maxlength, options)
56
- @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
57
+ expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
57
58
  active_model_length_validator([:title], options[:options])
58
59
  ])
59
60
 
@@ -61,32 +62,32 @@ describe 'string input' do
61
62
  concat(builder.input(:title))
62
63
  end)
63
64
 
64
- output_buffer.should 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
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(false)
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
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(true)
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 })
91
92
  end
92
93
 
@@ -97,14 +98,14 @@ 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
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(true)
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
- @new_post.should_receive(:specify_maxlength).at_least(1).and_return(false)
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 })
109
110
  end
110
111
  end
@@ -112,8 +113,8 @@ describe 'string input' do
112
113
  describe 'any conditional validation' do
113
114
  describe 'proc that calls an instance method' do
114
115
  it 'calls the method on the object' do
115
- @new_post.should_receive(:something?)
116
- @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
116
+ expect(@new_post).to receive(:something?)
117
+ expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
117
118
  active_model_presence_validator([:title], { :unless => -> { something? } })
118
119
  ])
119
120
  concat(semantic_form_for(@new_post) do |builder|
@@ -124,8 +125,8 @@ describe 'string input' do
124
125
 
125
126
  describe 'proc with arity that calls an instance method' do
126
127
  it 'calls the method on the object' do
127
- @new_post.should_receive(:something?)
128
- @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
128
+ expect(@new_post).to receive(:something?)
129
+ expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
129
130
  active_model_presence_validator([:title], { :unless => ->(user) { user.something? } })
130
131
  ])
131
132
  concat(semantic_form_for(@new_post) do |builder|
@@ -136,8 +137,8 @@ describe 'string input' do
136
137
 
137
138
  describe 'symbol method name' do
138
139
  it 'calls the method on the object if the method exists' do
139
- @new_post.should_receive(:something?)
140
- @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
140
+ expect(@new_post).to receive(:something?)
141
+ expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
141
142
  active_model_presence_validator([:title], { :unless => :something? })
142
143
  ])
143
144
  concat(semantic_form_for(@new_post) do |builder|
@@ -149,7 +150,7 @@ describe 'string input' do
149
150
  describe 'any other conditional' do
150
151
  it 'does not raise an error' do
151
152
  @conditional = double()
152
- @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
153
+ expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
153
154
  active_model_presence_validator([:title], { :unless => @conditional })
154
155
  ])
155
156
  concat(semantic_form_for(@new_post) do |builder|
@@ -164,22 +165,22 @@ 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 @@ 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should_not 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
- output_buffer.should 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 @@ 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
- output_buffer.should_not 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,12 +1,13 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'spec_helper'
3
4
 
4
- describe 'text input' do
5
+ RSpec.describe 'text input' do
5
6
 
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 @@ 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.replace ''
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
- output_buffer.should 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.replace ''
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
- output_buffer.should 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.replace ''
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
- output_buffer.should_not 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.replace ''
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
- output_buffer.should 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.replace ''
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
- output_buffer.should_not 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 @@ 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,34 +94,34 @@ 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should 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
- output_buffer.should have_tag("textarea[@required]")
118
+ expect(output_buffer.to_str).to have_tag("textarea[@required]")
118
119
  end
119
120
  end
120
121
  end
121
122
 
122
123
  context "when :autofocus is provided in :input_html" do
123
- before(:each) do
124
+ before(:example) do
124
125
  concat(semantic_form_for(@new_post) do |builder|
125
126
  concat(builder.input(:title, :input_html => {:autofocus => true}))
126
127
  end)
@@ -129,13 +130,13 @@ 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
- output_buffer.should 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.replace ''
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 @@ 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
- output_buffer.should 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 @@ 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
- output_buffer.should_not 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 @@ describe 'text input' do
160
161
 
161
162
  context "when :cols is missing in :input_html" do
162
163
  before do
163
- output_buffer.replace ''
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 @@ 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
- output_buffer.should 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 @@ 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
- output_buffer.should_not 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