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
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'date select input' do
4
+ RSpec.describe 'date select input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -28,30 +28,30 @@ describe 'date select input' do
28
28
  it_should_apply_error_logic_for_input_type(:date_select)
29
29
 
30
30
  it 'should have a legend and label with the label text inside the fieldset' do
31
- output_buffer.should have_tag('form li.date_select fieldset legend.label label', /Publish at/)
31
+ expect(output_buffer).to have_tag('form li.date_select fieldset legend.label label', :text => /Publish at/)
32
32
  end
33
33
 
34
34
  it 'should associate the legend label with the first select' do
35
- output_buffer.should have_tag('form li.date_select fieldset legend.label')
36
- output_buffer.should have_tag('form li.date_select fieldset legend.label label')
37
- output_buffer.should have_tag('form li.date_select fieldset legend.label label[@for]')
38
- output_buffer.should have_tag('form li.date_select fieldset legend.label label[@for="post_publish_at_1i"]')
35
+ expect(output_buffer).to have_tag('form li.date_select fieldset legend.label')
36
+ expect(output_buffer).to have_tag('form li.date_select fieldset legend.label label')
37
+ expect(output_buffer).to have_tag('form li.date_select fieldset legend.label label[@for]')
38
+ expect(output_buffer).to have_tag('form li.date_select fieldset legend.label label[@for="post_publish_at_1i"]')
39
39
  end
40
40
 
41
41
  it 'should have an ordered list of three items inside the fieldset' do
42
- output_buffer.should have_tag('form li.date_select fieldset ol.fragments-group')
43
- output_buffer.should have_tag('form li.date_select fieldset ol li.fragment', :count => 3)
42
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol.fragments-group')
43
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li.fragment', :count => 3)
44
44
  end
45
45
 
46
46
  it 'should have three labels for year, month and day' do
47
- output_buffer.should have_tag('form li.date_select fieldset ol li label', :count => 3)
48
- output_buffer.should have_tag('form li.date_select fieldset ol li label', /year/i)
49
- output_buffer.should have_tag('form li.date_select fieldset ol li label', /month/i)
50
- output_buffer.should have_tag('form li.date_select fieldset ol li label', /day/i)
47
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :count => 3)
48
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :text => /year/i)
49
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :text => /month/i)
50
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :text => /day/i)
51
51
  end
52
52
 
53
53
  it 'should have three selects for year, month and day' do
54
- output_buffer.should have_tag('form li.date_select fieldset ol li select', :count => 3)
54
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li select', :count => 3)
55
55
  end
56
56
  end
57
57
 
@@ -85,19 +85,19 @@ describe 'date select input' do
85
85
  end
86
86
 
87
87
  it 'should index the id of the wrapper' do
88
- output_buffer.should have_tag("li#post_author_attributes_3_created_at_input")
88
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
89
89
  end
90
90
 
91
91
  it 'should index the id of the select tag' do
92
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_1i")
93
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_2i")
94
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_3i")
92
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_1i")
93
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_2i")
94
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_3i")
95
95
  end
96
96
 
97
97
  it 'should index the name of the select tag' do
98
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(1i)]']")
99
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(2i)]']")
100
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(3i)]']")
98
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(1i)]']")
99
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(2i)]']")
100
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(3i)]']")
101
101
  end
102
102
 
103
103
  end
@@ -110,9 +110,9 @@ describe 'date select input' do
110
110
  concat(semantic_form_for(@new_post) do |builder|
111
111
  concat(builder.input(:created_at, :as => :date_select, :labels => { field => "another #{field} label" }))
112
112
  end)
113
- output_buffer.should have_tag('form li.date_select fieldset ol li label', :count => fields.length)
113
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :count => fields.length)
114
114
  fields.each do |f|
115
- output_buffer.should have_tag('form li.date_select fieldset ol li label', f == field ? /another #{f} label/i : /#{f}/i)
115
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :text => f == field ? /another #{f} label/i : /#{f}/i)
116
116
  end
117
117
  end
118
118
 
@@ -121,9 +121,9 @@ describe 'date select input' do
121
121
  concat(semantic_form_for(@new_post) do |builder|
122
122
  concat(builder.input(:created_at, :as => :date_select, :labels => { field => "" }))
123
123
  end)
124
- output_buffer.should have_tag('form li.date_select fieldset ol li label', :count => fields.length-1)
124
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :count => fields.length-1)
125
125
  fields.each do |f|
126
- output_buffer.should have_tag('form li.date_select fieldset ol li label', /#{f}/i) unless field == f
126
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :text => /#{f}/i) unless field == f
127
127
  end
128
128
  end
129
129
 
@@ -132,9 +132,9 @@ describe 'date select input' do
132
132
  concat(semantic_form_for(@new_post) do |builder|
133
133
  concat(builder.input(:created_at, :as => :date_select, :labels => { field => false }))
134
134
  end)
135
- output_buffer.should have_tag('form li.date_select fieldset ol li label', :count => fields.length-1)
135
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :count => fields.length-1)
136
136
  fields.each do |f|
137
- output_buffer.should have_tag('form li.date_select fieldset ol li label', /#{f}/i) unless field == f
137
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', /#{f}/i) unless field == f
138
138
  end
139
139
  end
140
140
 
@@ -143,7 +143,7 @@ describe 'date select input' do
143
143
  concat(semantic_form_for(@new_post) do |builder|
144
144
  concat(builder.input(:created_at, :as => :date_select, :include_seconds => true, :labels => { field => false }))
145
145
  end)
146
- output_buffer.should_not include(">")
146
+ expect(output_buffer).not_to include(">")
147
147
  end
148
148
 
149
149
  end
@@ -153,17 +153,31 @@ describe 'date select input' do
153
153
  concat(semantic_form_for(@new_post) do |builder|
154
154
  concat(builder.input(:created_at, :as => :date_select, :labels => false))
155
155
  end)
156
- output_buffer.should have_tag('form li.date_select fieldset ol li label', :count => 0)
156
+ expect(output_buffer).to have_tag('form li.date_select fieldset ol li label', :count => 0)
157
157
  end
158
158
  end
159
-
159
+
160
+ describe ":selected option for setting a value" do
161
+ it "should set the selected value for the form" do
162
+ concat(
163
+ semantic_form_for(@new_post) do |f|
164
+ concat(f.input(:created_at, :as => :datetime_select, :selected => Date.new(2018, 10, 4)))
165
+ end
166
+ )
167
+
168
+ expect(output_buffer).to have_tag "option[value='2018'][selected='selected']"
169
+ expect(output_buffer).to have_tag "option[value='10'][selected='selected']"
170
+ expect(output_buffer).to have_tag "option[value='4'][selected='selected']"
171
+ end
172
+ end
173
+
160
174
  describe "when required" do
161
175
  it "should add the required attribute to the input's html options" do
162
176
  with_config :use_required_attribute, true do
163
177
  concat(semantic_form_for(@new_post) do |builder|
164
178
  concat(builder.input(:title, :as => :date_select, :required => true))
165
179
  end)
166
- output_buffer.should have_tag("select[@required]", :count => 3)
180
+ expect(output_buffer).to have_tag("select[@required]", :count => 3)
167
181
  end
168
182
  end
169
183
  end
@@ -177,11 +191,11 @@ describe 'date select input' do
177
191
  end
178
192
 
179
193
  it "should include a hidden input for day" do
180
- output_buffer.should have_tag('input[@type="hidden"][@name="post[publish_at(3i)]"][@value="1"]')
194
+ expect(output_buffer).to have_tag('input[@type="hidden"][@name="post[publish_at(3i)]"][@value="1"]')
181
195
  end
182
196
 
183
197
  it "should not include a select for day" do
184
- output_buffer.should_not have_tag('select[@name="post[publish_at(3i)]"]')
198
+ expect(output_buffer).not_to have_tag('select[@name="post[publish_at(3i)]"]')
185
199
  end
186
200
  end
187
201
 
@@ -194,11 +208,11 @@ describe 'date select input' do
194
208
  end
195
209
 
196
210
  it "should include a hidden input for month" do
197
- output_buffer.should have_tag('input[@type="hidden"][@name="post[publish_at(2i)]"][@value="1"]')
211
+ expect(output_buffer).to have_tag('input[@type="hidden"][@name="post[publish_at(2i)]"][@value="1"]')
198
212
  end
199
213
 
200
214
  it "should not include a select for month" do
201
- output_buffer.should_not have_tag('select[@name="post[publish_at(2i)]"]')
215
+ expect(output_buffer).not_to have_tag('select[@name="post[publish_at(2i)]"]')
202
216
  end
203
217
  end
204
218
 
@@ -211,11 +225,11 @@ describe 'date select input' do
211
225
  end
212
226
 
213
227
  it "should include a hidden input for month" do
214
- output_buffer.should have_tag("input[@type=\"hidden\"][@name=\"post[publish_at(1i)]\"][@value=\"#{Time.now.year}\"]")
228
+ expect(output_buffer).to have_tag("input[@type=\"hidden\"][@name=\"post[publish_at(1i)]\"][@value=\"#{Time.now.year}\"]")
215
229
  end
216
230
 
217
231
  it "should not include a select for month" do
218
- output_buffer.should_not have_tag('select[@name="post[publish_at(1i)]"]')
232
+ expect(output_buffer).not_to have_tag('select[@name="post[publish_at(1i)]"]')
219
233
  end
220
234
  end
221
235
 
@@ -228,7 +242,7 @@ describe 'date select input' do
228
242
  end
229
243
 
230
244
  it 'should associate the legend label with the new first select' do
231
- output_buffer.should have_tag('form li.date_select fieldset legend.label label[@for="post_publish_at_3i"]')
245
+ expect(output_buffer).to have_tag('form li.date_select fieldset legend.label label[@for="post_publish_at_3i"]')
232
246
  end
233
247
  end
234
248
 
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'datetime_picker input' do
4
+ RSpec.describe 'datetime_picker input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -44,7 +44,7 @@ describe 'datetime_picker input' do
44
44
  concat(f.input(:publish_at, :as => :datetime_picker))
45
45
  end
46
46
  )
47
- output_buffer.should have_tag "input[type='datetime-local']"
47
+ expect(output_buffer).to have_tag "input[type='datetime-local']"
48
48
  end
49
49
 
50
50
  it "can be set to true for a datetime-local" do
@@ -53,7 +53,7 @@ describe 'datetime_picker input' do
53
53
  concat(f.input(:publish_at, :as => :datetime_picker, :local => true))
54
54
  end
55
55
  )
56
- output_buffer.should have_tag "input[type='datetime-local']"
56
+ expect(output_buffer).to have_tag "input[type='datetime-local']"
57
57
  end
58
58
 
59
59
  it "can be set to false for a datetime" do
@@ -62,7 +62,7 @@ describe 'datetime_picker input' do
62
62
  concat(f.input(:publish_at, :as => :datetime_picker, :local => false))
63
63
  end
64
64
  )
65
- output_buffer.should have_tag "input[type='datetime']"
65
+ expect(output_buffer).to have_tag "input[type='datetime']"
66
66
  end
67
67
 
68
68
  end
@@ -75,7 +75,7 @@ describe 'datetime_picker input' do
75
75
  concat(f.input(:publish_at, :as => :datetime_picker))
76
76
  end
77
77
  )
78
- output_buffer.should have_tag "input[size='16']"
78
+ expect(output_buffer).to have_tag "input[size='16']"
79
79
  end
80
80
 
81
81
  it "can be set from :input_html options" do
@@ -84,7 +84,7 @@ describe 'datetime_picker input' do
84
84
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :size => "11" }))
85
85
  end
86
86
  )
87
- output_buffer.should have_tag "input[size='11']"
87
+ expect(output_buffer).to have_tag "input[size='11']"
88
88
  end
89
89
 
90
90
  it "can be set from options (ignoring input_html)" do
@@ -93,7 +93,7 @@ describe 'datetime_picker input' do
93
93
  concat(f.input(:publish_at, :as => :datetime_picker, :size => '12', :input_html => { :size => "11" }))
94
94
  end
95
95
  )
96
- output_buffer.should have_tag "input[size='12']"
96
+ expect(output_buffer).to have_tag "input[size='12']"
97
97
  end
98
98
 
99
99
  end
@@ -106,7 +106,7 @@ describe 'datetime_picker input' do
106
106
  concat(f.input(:publish_at, :as => :datetime_picker))
107
107
  end
108
108
  )
109
- output_buffer.should have_tag "input[maxlength='16']"
109
+ expect(output_buffer).to have_tag "input[maxlength='16']"
110
110
  end
111
111
 
112
112
  it "can be set from :input_html options" do
@@ -115,7 +115,7 @@ describe 'datetime_picker input' do
115
115
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :maxlength => "11" }))
116
116
  end
117
117
  )
118
- output_buffer.should have_tag "input[maxlength='11']"
118
+ expect(output_buffer).to have_tag "input[maxlength='11']"
119
119
  end
120
120
 
121
121
  it "can be set from options (ignoring input_html)" do
@@ -124,7 +124,7 @@ describe 'datetime_picker input' do
124
124
  concat(f.input(:publish_at, :as => :datetime_picker, :maxlength => 12, :input_html => { :maxlength => "11" }))
125
125
  end
126
126
  )
127
- output_buffer.should have_tag "input[maxlength='12']"
127
+ expect(output_buffer).to have_tag "input[maxlength='12']"
128
128
  end
129
129
 
130
130
  end
@@ -139,7 +139,7 @@ describe 'datetime_picker input' do
139
139
  concat(f.input(:publish_at, :as => :datetime_picker ))
140
140
  end
141
141
  )
142
- output_buffer.should_not have_tag "li input[value]"
142
+ expect(output_buffer).not_to have_tag "li input[value]"
143
143
  end
144
144
 
145
145
  it "can be set from :input_html options" do
@@ -148,7 +148,7 @@ describe 'datetime_picker input' do
148
148
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T23:00:00" }))
149
149
  end
150
150
  )
151
- output_buffer.should have_tag "input[value='1111-11-11T23:00:00']"
151
+ expect(output_buffer).to have_tag "input[value='1111-11-11T23:00:00']"
152
152
  end
153
153
 
154
154
  end
@@ -157,7 +157,7 @@ describe 'datetime_picker input' do
157
157
 
158
158
  before do
159
159
  @date = Date.new(2000, 11, 11)
160
- @new_post.stub(:publish_at).and_return(@date)
160
+ allow(@new_post).to receive(:publish_at).and_return(@date)
161
161
  end
162
162
 
163
163
  it "renders the date as YYYY-MM-DDT00:00:00" do
@@ -166,7 +166,7 @@ describe 'datetime_picker input' do
166
166
  concat(f.input(:publish_at, :as => :datetime_picker ))
167
167
  end
168
168
  )
169
- output_buffer.should have_tag "input[value='2000-11-11T00:00:00']"
169
+ expect(output_buffer).to have_tag "input[value='2000-11-11T00:00:00']"
170
170
  end
171
171
 
172
172
  it "can be set from :input_html options" do
@@ -175,7 +175,7 @@ describe 'datetime_picker input' do
175
175
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T00:00:00" }))
176
176
  end
177
177
  )
178
- output_buffer.should have_tag "input[value='1111-11-11T00:00:00']"
178
+ expect(output_buffer).to have_tag "input[value='1111-11-11T00:00:00']"
179
179
  end
180
180
 
181
181
  end
@@ -184,7 +184,7 @@ describe 'datetime_picker input' do
184
184
 
185
185
  before do
186
186
  @time = Time.utc(2000,11,11,11,11,11)
187
- @new_post.stub(:publish_at).and_return(@time)
187
+ allow(@new_post).to receive(:publish_at).and_return(@time)
188
188
  end
189
189
 
190
190
  it "renders the time as a YYYY-MM-DD HH:MM" do
@@ -193,7 +193,7 @@ describe 'datetime_picker input' do
193
193
  concat(f.input(:publish_at, :as => :datetime_picker ))
194
194
  end
195
195
  )
196
- output_buffer.should have_tag "input[value='2000-11-11T11:11:11']"
196
+ expect(output_buffer).to have_tag "input[value='2000-11-11T11:11:11']"
197
197
  end
198
198
 
199
199
  it "can be set from :input_html options" do
@@ -202,7 +202,7 @@ describe 'datetime_picker input' do
202
202
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T11:11:11" }))
203
203
  end
204
204
  )
205
- output_buffer.should have_tag "input[value='1111-11-11T11:11:11']"
205
+ expect(output_buffer).to have_tag "input[value='1111-11-11T11:11:11']"
206
206
  end
207
207
 
208
208
  end
@@ -210,7 +210,7 @@ describe 'datetime_picker input' do
210
210
  context "when method returns an empty String" do
211
211
 
212
212
  before do
213
- @new_post.stub(:publish_at).and_return("")
213
+ allow(@new_post).to receive(:publish_at).and_return("")
214
214
  end
215
215
 
216
216
  it "will be empty" do
@@ -219,7 +219,7 @@ describe 'datetime_picker input' do
219
219
  concat(f.input(:publish_at, :as => :datetime_picker ))
220
220
  end
221
221
  )
222
- output_buffer.should have_tag "input[value='']"
222
+ expect(output_buffer).to have_tag "input[value='']"
223
223
  end
224
224
 
225
225
  it "can be set from :input_html options" do
@@ -228,7 +228,7 @@ describe 'datetime_picker input' do
228
228
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T11:11:11" }))
229
229
  end
230
230
  )
231
- output_buffer.should have_tag "input[value='1111-11-11T11:11:11']"
231
+ expect(output_buffer).to have_tag "input[value='1111-11-11T11:11:11']"
232
232
  end
233
233
 
234
234
  end
@@ -236,7 +236,7 @@ describe 'datetime_picker input' do
236
236
  context "when method returns a String" do
237
237
 
238
238
  before do
239
- @new_post.stub(:publish_at).and_return("yeah")
239
+ allow(@new_post).to receive(:publish_at).and_return("yeah")
240
240
  end
241
241
 
242
242
  it "will be the string" do
@@ -245,7 +245,7 @@ describe 'datetime_picker input' do
245
245
  concat(f.input(:publish_at, :as => :datetime_picker ))
246
246
  end
247
247
  )
248
- output_buffer.should have_tag "input[value='yeah']"
248
+ expect(output_buffer).to have_tag "input[value='yeah']"
249
249
  end
250
250
 
251
251
  it "can be set from :input_html options" do
@@ -254,7 +254,7 @@ describe 'datetime_picker input' do
254
254
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :value => "1111-11-11T11:11:11" }))
255
255
  end
256
256
  )
257
- output_buffer.should have_tag "input[value='1111-11-11T11:11:11']"
257
+ expect(output_buffer).to have_tag "input[value='1111-11-11T11:11:11']"
258
258
  end
259
259
 
260
260
  end
@@ -269,7 +269,7 @@ describe 'datetime_picker input' do
269
269
  concat(f.input(:publish_at, :as => :datetime_picker))
270
270
  end
271
271
  )
272
- output_buffer.should_not have_tag "input[min]"
272
+ expect(output_buffer).not_to have_tag "input[min]"
273
273
  end
274
274
 
275
275
  it "can be set from :input_html options" do
@@ -278,7 +278,7 @@ describe 'datetime_picker input' do
278
278
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :min => "1970-01-01 12:00" }))
279
279
  end
280
280
  )
281
- output_buffer.should have_tag "input[min='1970-01-01 12:00']"
281
+ expect(output_buffer).to have_tag "input[min='1970-01-01 12:00']"
282
282
  end
283
283
 
284
284
  end
@@ -291,7 +291,7 @@ describe 'datetime_picker input' do
291
291
  concat(f.input(:publish_at, :as => :datetime_picker))
292
292
  end
293
293
  )
294
- output_buffer.should_not have_tag "input[max]"
294
+ expect(output_buffer).not_to have_tag "input[max]"
295
295
  end
296
296
 
297
297
  it "can be set from :input_html options" do
@@ -300,7 +300,7 @@ describe 'datetime_picker input' do
300
300
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :max => "1970-01-01 12:00" }))
301
301
  end
302
302
  )
303
- output_buffer.should have_tag "input[max='1970-01-01 12:00']"
303
+ expect(output_buffer).to have_tag "input[max='1970-01-01 12:00']"
304
304
  end
305
305
 
306
306
  end
@@ -313,7 +313,7 @@ describe 'datetime_picker input' do
313
313
  concat(f.input(:publish_at, :as => :datetime_picker))
314
314
  end
315
315
  )
316
- output_buffer.should have_tag "input[step='1']"
316
+ expect(output_buffer).to have_tag "input[step='1']"
317
317
  end
318
318
 
319
319
  it "can be set from :input_html options" do
@@ -322,7 +322,7 @@ describe 'datetime_picker input' do
322
322
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :step => "5" }))
323
323
  end
324
324
  )
325
- output_buffer.should have_tag "input[step='5']"
325
+ expect(output_buffer).to have_tag "input[step='5']"
326
326
  end
327
327
 
328
328
  describe "macros" do
@@ -337,56 +337,56 @@ describe 'datetime_picker input' do
337
337
  context ":second" do
338
338
  let(:step) { :second }
339
339
  it "uses 1" do
340
- output_buffer.should have_tag "input[step='1']"
340
+ expect(output_buffer).to have_tag "input[step='1']"
341
341
  end
342
342
  end
343
343
 
344
344
  context ":minute" do
345
345
  let(:step) { :minute }
346
346
  it "uses 60" do
347
- output_buffer.should have_tag "input[step='60']"
347
+ expect(output_buffer).to have_tag "input[step='60']"
348
348
  end
349
349
  end
350
350
 
351
351
  context ":fifteen_minutes" do
352
352
  let(:step) { :fifteen_minutes }
353
353
  it "uses 900" do
354
- output_buffer.should have_tag "input[step='900']"
354
+ expect(output_buffer).to have_tag "input[step='900']"
355
355
  end
356
356
  end
357
357
 
358
358
  context ":quarter_hour" do
359
359
  let(:step) { :quarter_hour }
360
360
  it "uses 900" do
361
- output_buffer.should have_tag "input[step='900']"
361
+ expect(output_buffer).to have_tag "input[step='900']"
362
362
  end
363
363
  end
364
364
 
365
365
  context ":thirty_minutes" do
366
366
  let(:step) { :thirty_minutes }
367
367
  it "uses 1800" do
368
- output_buffer.should have_tag "input[step='1800']"
368
+ expect(output_buffer).to have_tag "input[step='1800']"
369
369
  end
370
370
  end
371
371
 
372
372
  context ":half_hour" do
373
373
  let(:step) { :half_hour }
374
374
  it "uses 1800" do
375
- output_buffer.should have_tag "input[step='1800']"
375
+ expect(output_buffer).to have_tag "input[step='1800']"
376
376
  end
377
377
  end
378
378
 
379
379
  context ":hour" do
380
380
  let(:step) { :hour }
381
381
  it "uses 3600" do
382
- output_buffer.should have_tag "input[step='3600']"
382
+ expect(output_buffer).to have_tag "input[step='3600']"
383
383
  end
384
384
  end
385
385
 
386
386
  context ":sixty_minutes" do
387
387
  let(:step) { :sixty_minutes }
388
388
  it "uses 3600" do
389
- output_buffer.should have_tag "input[step='3600']"
389
+ expect(output_buffer).to have_tag "input[step='3600']"
390
390
  end
391
391
  end
392
392
 
@@ -402,7 +402,7 @@ describe 'datetime_picker input' do
402
402
  concat(f.input(:publish_at, :as => :datetime_picker))
403
403
  end
404
404
  )
405
- output_buffer.should_not have_tag "input[placeholder]"
405
+ expect(output_buffer).not_to have_tag "input[placeholder]"
406
406
  end
407
407
 
408
408
  it "can be set from :input_html options" do
@@ -411,7 +411,7 @@ describe 'datetime_picker input' do
411
411
  concat(f.input(:publish_at, :as => :datetime_picker, :input_html => { :placeholder => "1970-01-01 00:00" }))
412
412
  end
413
413
  )
414
- output_buffer.should have_tag "input[placeholder='1970-01-01 00:00']"
414
+ expect(output_buffer).to have_tag "input[placeholder='1970-01-01 00:00']"
415
415
  end
416
416
 
417
417
  context "with i18n set" do
@@ -424,7 +424,7 @@ describe 'datetime_picker input' do
424
424
  concat(semantic_form_for(@new_post) do |builder|
425
425
  concat(builder.input(:publish_at, :as => :datetime_picker))
426
426
  end)
427
- output_buffer.should have_tag('input[@placeholder="YYYY-MM-DD HH:MM"]')
427
+ expect(output_buffer).to have_tag('input[@placeholder="YYYY-MM-DD HH:MM"]')
428
428
  end
429
429
  end
430
430
 
@@ -433,7 +433,7 @@ describe 'datetime_picker input' do
433
433
  concat(semantic_form_for(@new_post) do |builder|
434
434
  concat(builder.input(:publish_at, :as => :datetime_picker, :input_html => { :placeholder => "Something" }))
435
435
  end)
436
- output_buffer.should have_tag('input[@placeholder="Something"]')
436
+ expect(output_buffer).to have_tag('input[@placeholder="Something"]')
437
437
  end
438
438
  end
439
439
  end
@@ -464,15 +464,15 @@ describe 'datetime_picker input' do
464
464
  end
465
465
 
466
466
  it 'should index the id of the wrapper' do
467
- output_buffer.should have_tag("li#post_author_attributes_3_created_at_input")
467
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
468
468
  end
469
469
 
470
470
  it 'should index the id of the select tag' do
471
- output_buffer.should have_tag("input#post_author_attributes_3_created_at")
471
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at")
472
472
  end
473
473
 
474
474
  it 'should index the name of the select tag' do
475
- output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at]']")
475
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at]']")
476
476
  end
477
477
  end
478
478
 
@@ -482,7 +482,7 @@ describe 'datetime_picker input' do
482
482
  concat(semantic_form_for(@new_post) do |builder|
483
483
  concat(builder.input(:publish_at, :as => :datetime_picker, :required => true))
484
484
  end)
485
- output_buffer.should have_tag("input[@required]")
485
+ expect(output_buffer).to have_tag("input[@required]")
486
486
  end
487
487
  end
488
488
  end