formtastic 3.1.1 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.gitignore +3 -2
  4. data/.travis.yml +29 -24
  5. data/CHANGELOG.md +49 -0
  6. data/DEPRECATIONS +4 -1
  7. data/Gemfile.lock +104 -0
  8. data/{README.textile → README.md} +178 -166
  9. data/Rakefile +20 -1
  10. data/app/assets/stylesheets/formtastic.css +1 -1
  11. data/bin/appraisal +8 -0
  12. data/formtastic.gemspec +9 -15
  13. data/gemfiles/rails_5.2/Gemfile +5 -0
  14. data/gemfiles/rails_6.0/Gemfile +5 -0
  15. data/gemfiles/rails_edge/Gemfile +13 -0
  16. data/lib/formtastic.rb +9 -11
  17. data/lib/formtastic/actions.rb +6 -3
  18. data/lib/formtastic/deprecation.rb +1 -38
  19. data/lib/formtastic/engine.rb +3 -1
  20. data/lib/formtastic/form_builder.rb +11 -24
  21. data/lib/formtastic/helpers.rb +1 -1
  22. data/lib/formtastic/helpers/action_helper.rb +1 -48
  23. data/lib/formtastic/helpers/enum.rb +13 -0
  24. data/lib/formtastic/helpers/errors_helper.rb +2 -2
  25. data/lib/formtastic/helpers/fieldset_wrapper.rb +13 -9
  26. data/lib/formtastic/helpers/form_helper.rb +1 -1
  27. data/lib/formtastic/helpers/input_helper.rb +23 -77
  28. data/lib/formtastic/helpers/inputs_helper.rb +27 -22
  29. data/lib/formtastic/i18n.rb +1 -1
  30. data/lib/formtastic/inputs.rb +32 -29
  31. data/lib/formtastic/inputs/base/choices.rb +1 -1
  32. data/lib/formtastic/inputs/base/collections.rb +43 -10
  33. data/lib/formtastic/inputs/base/database.rb +7 -2
  34. data/lib/formtastic/inputs/base/errors.rb +4 -4
  35. data/lib/formtastic/inputs/base/hints.rb +1 -1
  36. data/lib/formtastic/inputs/base/html.rb +7 -6
  37. data/lib/formtastic/inputs/base/naming.rb +4 -4
  38. data/lib/formtastic/inputs/base/options.rb +2 -3
  39. data/lib/formtastic/inputs/base/timeish.rb +5 -1
  40. data/lib/formtastic/inputs/base/validations.rb +38 -12
  41. data/lib/formtastic/inputs/check_boxes_input.rb +13 -5
  42. data/lib/formtastic/inputs/color_input.rb +0 -1
  43. data/lib/formtastic/inputs/country_input.rb +3 -1
  44. data/lib/formtastic/inputs/radio_input.rb +20 -0
  45. data/lib/formtastic/inputs/select_input.rb +29 -1
  46. data/lib/formtastic/inputs/time_zone_input.rb +16 -6
  47. data/lib/formtastic/localizer.rb +20 -22
  48. data/lib/formtastic/namespaced_class_finder.rb +1 -1
  49. data/lib/formtastic/version.rb +1 -1
  50. data/lib/generators/formtastic/form/form_generator.rb +1 -1
  51. data/lib/generators/formtastic/input/input_generator.rb +46 -0
  52. data/lib/generators/templates/formtastic.rb +14 -13
  53. data/lib/generators/templates/input.rb +19 -0
  54. data/script/integration-template.rb +71 -0
  55. data/script/integration.sh +19 -0
  56. data/spec/action_class_finder_spec.rb +1 -1
  57. data/spec/actions/button_action_spec.rb +8 -8
  58. data/spec/actions/generic_action_spec.rb +60 -60
  59. data/spec/actions/input_action_spec.rb +7 -7
  60. data/spec/actions/link_action_spec.rb +10 -10
  61. data/spec/builder/custom_builder_spec.rb +36 -20
  62. data/spec/builder/error_proc_spec.rb +4 -4
  63. data/spec/builder/semantic_fields_for_spec.rb +27 -27
  64. data/spec/fast_spec_helper.rb +12 -0
  65. data/spec/generators/formtastic/form/form_generator_spec.rb +25 -25
  66. data/spec/generators/formtastic/input/input_generator_spec.rb +124 -0
  67. data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
  68. data/spec/helpers/action_helper_spec.rb +328 -10
  69. data/spec/helpers/actions_helper_spec.rb +17 -17
  70. data/spec/helpers/form_helper_spec.rb +37 -37
  71. data/spec/helpers/input_helper_spec.rb +975 -2
  72. data/spec/helpers/inputs_helper_spec.rb +120 -105
  73. data/spec/helpers/reflection_helper_spec.rb +3 -3
  74. data/spec/helpers/semantic_errors_helper_spec.rb +22 -22
  75. data/spec/i18n_spec.rb +26 -26
  76. data/spec/input_class_finder_spec.rb +1 -1
  77. data/spec/inputs/base/collections_spec.rb +76 -0
  78. data/spec/inputs/base/validations_spec.rb +480 -0
  79. data/spec/inputs/boolean_input_spec.rb +55 -55
  80. data/spec/inputs/check_boxes_input_spec.rb +155 -108
  81. data/spec/inputs/color_input_spec.rb +51 -63
  82. data/spec/inputs/country_input_spec.rb +20 -20
  83. data/spec/inputs/custom_input_spec.rb +2 -6
  84. data/spec/inputs/datalist_input_spec.rb +1 -1
  85. data/spec/inputs/date_picker_input_spec.rb +42 -42
  86. data/spec/inputs/date_select_input_spec.rb +51 -37
  87. data/spec/inputs/datetime_picker_input_spec.rb +46 -46
  88. data/spec/inputs/datetime_select_input_spec.rb +53 -37
  89. data/spec/inputs/email_input_spec.rb +5 -5
  90. data/spec/inputs/file_input_spec.rb +6 -6
  91. data/spec/inputs/hidden_input_spec.rb +18 -18
  92. data/spec/inputs/include_blank_spec.rb +8 -8
  93. data/spec/inputs/label_spec.rb +20 -20
  94. data/spec/inputs/number_input_spec.rb +112 -112
  95. data/spec/inputs/password_input_spec.rb +5 -5
  96. data/spec/inputs/phone_input_spec.rb +5 -5
  97. data/spec/inputs/placeholder_spec.rb +5 -5
  98. data/spec/inputs/radio_input_spec.rb +84 -58
  99. data/spec/inputs/range_input_spec.rb +66 -66
  100. data/spec/inputs/readonly_spec.rb +50 -0
  101. data/spec/inputs/search_input_spec.rb +5 -5
  102. data/spec/inputs/select_input_spec.rb +149 -93
  103. data/spec/inputs/string_input_spec.rb +23 -23
  104. data/spec/inputs/text_input_spec.rb +16 -16
  105. data/spec/inputs/time_picker_input_spec.rb +43 -43
  106. data/spec/inputs/time_select_input_spec.rb +67 -54
  107. data/spec/inputs/time_zone_input_spec.rb +54 -28
  108. data/spec/inputs/url_input_spec.rb +5 -5
  109. data/spec/inputs/with_options_spec.rb +7 -7
  110. data/spec/localizer_spec.rb +17 -17
  111. data/spec/namespaced_class_finder_spec.rb +2 -2
  112. data/spec/schema.rb +21 -0
  113. data/spec/spec_helper.rb +165 -253
  114. data/spec/support/custom_macros.rb +72 -75
  115. data/spec/support/shared_examples.rb +0 -1232
  116. data/spec/support/test_environment.rb +23 -9
  117. metadata +67 -174
  118. data/Appraisals +0 -29
  119. data/CHANGELOG +0 -31
  120. data/gemfiles/rails_3.2.gemfile +0 -7
  121. data/gemfiles/rails_4.0.4.gemfile +0 -7
  122. data/gemfiles/rails_4.1.gemfile +0 -7
  123. data/gemfiles/rails_4.2.gemfile +0 -7
  124. data/gemfiles/rails_4.gemfile +0 -7
  125. data/gemfiles/rails_edge.gemfile +0 -10
  126. data/lib/formtastic/util.rb +0 -53
  127. data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
  128. data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
  129. data/spec/support/deferred_garbage_collection.rb +0 -21
  130. 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 'datetime select input' do
4
+ RSpec.describe 'datetime select input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -29,32 +29,32 @@ describe 'datetime select input' do
29
29
  it_should_apply_error_logic_for_input_type(:datetime_select)
30
30
 
31
31
  it 'should have a legend and label with the label text inside the fieldset' do
32
- output_buffer.should have_tag('form li.datetime_select fieldset legend.label label', /Publish at/)
32
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label', :text => /Publish at/)
33
33
  end
34
34
 
35
35
  it 'should associate the legend label with the first select' do
36
- output_buffer.should have_tag('form li.datetime_select fieldset legend.label')
37
- output_buffer.should have_tag('form li.datetime_select fieldset legend.label label')
38
- output_buffer.should have_tag('form li.datetime_select fieldset legend.label label[@for]')
39
- output_buffer.should have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_1i"]')
36
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label')
37
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label')
38
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label[@for]')
39
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_1i"]')
40
40
  end
41
41
 
42
42
  it 'should have an ordered list of five items inside the fieldset' do
43
- output_buffer.should have_tag('form li.datetime_select fieldset ol.fragments-group')
44
- output_buffer.should have_tag('form li.datetime_select fieldset ol li.fragment', :count => 5)
43
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol.fragments-group')
44
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li.fragment', :count => 5)
45
45
  end
46
46
 
47
47
  it 'should have five labels for year, month and day' do
48
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', :count => 5)
49
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', /year/i)
50
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', /month/i)
51
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', /day/i)
52
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', /hour/i)
53
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', /min/i)
48
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => 5)
49
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /year/i)
50
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /month/i)
51
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /day/i)
52
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /hour/i)
53
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /min/i)
54
54
  end
55
55
 
56
56
  it 'should have five selects' do
57
- output_buffer.should have_tag('form li.datetime_select fieldset ol li select', :count => 5)
57
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li select', :count => 5)
58
58
  end
59
59
  end
60
60
 
@@ -90,23 +90,23 @@ describe 'datetime select input' do
90
90
  end
91
91
 
92
92
  it 'should index the id of the wrapper' do
93
- output_buffer.should have_tag("li#post_author_attributes_3_created_at_input")
93
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
94
94
  end
95
95
 
96
96
  it 'should index the id of the select tag' do
97
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_1i")
98
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_2i")
99
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_3i")
100
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_4i")
101
- output_buffer.should have_tag("select#post_author_attributes_3_created_at_5i")
97
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_1i")
98
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_2i")
99
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_3i")
100
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_4i")
101
+ expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_5i")
102
102
  end
103
103
 
104
104
  it 'should index the name of the select tag' do
105
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(1i)]']")
106
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(2i)]']")
107
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(3i)]']")
108
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
109
- output_buffer.should have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
105
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(1i)]']")
106
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(2i)]']")
107
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(3i)]']")
108
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
109
+ expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
110
110
  end
111
111
 
112
112
  end
@@ -120,9 +120,9 @@ describe 'datetime select input' do
120
120
  concat(semantic_form_for(@new_post) do |builder|
121
121
  concat(builder.input(:created_at, :as => :datetime_select, :labels => { field => "another #{field} label" }))
122
122
  end)
123
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', :count => fields.length)
123
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length)
124
124
  fields.each do |f|
125
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', f == field ? /another #{f} label/i : /#{f}/i)
125
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => f == field ? /another #{f} label/i : /#{f}/i)
126
126
  end
127
127
  end
128
128
 
@@ -131,9 +131,9 @@ describe 'datetime select input' do
131
131
  concat(semantic_form_for(@new_post) do |builder|
132
132
  concat(builder.input(:created_at, :as => :datetime_select, :labels => { field => "" }))
133
133
  end)
134
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
134
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
135
135
  fields.each do |f|
136
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', /#{f}/i) unless field == f
136
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /#{f}/i) unless field == f
137
137
  end
138
138
  end
139
139
 
@@ -142,9 +142,9 @@ describe 'datetime select input' do
142
142
  concat(semantic_form_for(@new_post) do |builder|
143
143
  concat(builder.input(:created_at, :as => :datetime_select, :labels => { field => false }))
144
144
  end)
145
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
145
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => fields.length-1)
146
146
  fields.each do |f|
147
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', /#{f}/i) unless field == f
147
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :text => /#{f}/i) unless field == f
148
148
  end
149
149
  end
150
150
 
@@ -153,7 +153,7 @@ describe 'datetime select input' do
153
153
  concat(semantic_form_for(@new_post) do |builder|
154
154
  concat(builder.input(:created_at, :as => :datetime_select, :include_seconds => true, :labels => { field => false }))
155
155
  end)
156
- output_buffer.should_not include(">")
156
+ expect(output_buffer).not_to include(">")
157
157
  end
158
158
  end
159
159
 
@@ -162,17 +162,33 @@ describe 'datetime select input' do
162
162
  concat(semantic_form_for(@new_post) do |builder|
163
163
  concat(builder.input(:created_at, :as => :datetime_select, :labels => false))
164
164
  end)
165
- output_buffer.should have_tag('form li.datetime_select fieldset ol li label', :count => 0)
165
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset ol li label', :count => 0)
166
166
  end
167
167
  end
168
-
168
+
169
+ describe ":selected option for setting a value" do
170
+ it "should set the selected value for the form" do
171
+ concat(
172
+ semantic_form_for(@new_post) do |f|
173
+ concat(f.input(:created_at, :as => :datetime_select, :selected => DateTime.new(2018, 10, 4, 12, 00)))
174
+ end
175
+ )
176
+
177
+ expect(output_buffer).to have_tag "option[value='2018'][selected='selected']"
178
+ expect(output_buffer).to have_tag "option[value='10'][selected='selected']"
179
+ expect(output_buffer).to have_tag "option[value='4'][selected='selected']"
180
+ expect(output_buffer).to have_tag "option[value='12'][selected='selected']"
181
+ expect(output_buffer).to have_tag "option[value='00'][selected='selected']"
182
+ end
183
+ end
184
+
169
185
  describe "when required" do
170
186
  it "should add the required attribute to the input's html options" do
171
187
  with_config :use_required_attribute, true do
172
188
  concat(semantic_form_for(@new_post) do |builder|
173
189
  concat(builder.input(:title, :as => :datetime_select, :required => true))
174
190
  end)
175
- output_buffer.should have_tag("select[@required]", :count => 5)
191
+ expect(output_buffer).to have_tag("select[@required]", :count => 5)
176
192
  end
177
193
  end
178
194
  end
@@ -186,7 +202,7 @@ describe 'datetime select input' do
186
202
  end
187
203
 
188
204
  it 'should associate the legend label with the new first select' do
189
- output_buffer.should have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_3i"]')
205
+ expect(output_buffer).to have_tag('form li.datetime_select fieldset legend.label label[@for="post_publish_at_3i"]')
190
206
  end
191
207
  end
192
208
 
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'email input' do
4
+ RSpec.describe 'email input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -56,15 +56,15 @@ describe 'email input' do
56
56
  end
57
57
 
58
58
  it 'should index the id of the wrapper' do
59
- output_buffer.should have_tag("li#post_author_attributes_3_name_input")
59
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
60
60
  end
61
61
 
62
62
  it 'should index the id of the select tag' do
63
- output_buffer.should have_tag("input#post_author_attributes_3_name")
63
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
64
64
  end
65
65
 
66
66
  it 'should index the name of the select tag' do
67
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
67
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
68
68
  end
69
69
 
70
70
  end
@@ -76,7 +76,7 @@ describe 'email input' do
76
76
  concat(semantic_form_for(@new_post) do |builder|
77
77
  concat(builder.input(:title, :as => :email, :required => true))
78
78
  end)
79
- output_buffer.should have_tag("input[@required]")
79
+ expect(output_buffer).to have_tag("input[@required]")
80
80
  end
81
81
  end
82
82
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'file input' do
4
+ RSpec.describe 'file input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -27,7 +27,7 @@ describe 'file input' do
27
27
  concat(semantic_form_for(@new_post) do |builder|
28
28
  concat(builder.input(:title, :as => :file, :input_html => { :class => 'myclass' }))
29
29
  end)
30
- output_buffer.should have_tag("form li input.myclass")
30
+ expect(output_buffer).to have_tag("form li input.myclass")
31
31
  end
32
32
 
33
33
  describe "when namespace is provided" do
@@ -60,15 +60,15 @@ describe 'file input' do
60
60
  end
61
61
 
62
62
  it 'should index the id of the wrapper' do
63
- output_buffer.should have_tag("li#post_author_attributes_3_name_input")
63
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
64
64
  end
65
65
 
66
66
  it 'should index the id of the select tag' do
67
- output_buffer.should have_tag("input#post_author_attributes_3_name")
67
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
68
68
  end
69
69
 
70
70
  it 'should index the name of the select tag' do
71
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
71
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
72
72
  end
73
73
 
74
74
  end
@@ -80,7 +80,7 @@ describe 'file input' do
80
80
  concat(semantic_form_for(@new_post) do |builder|
81
81
  concat(builder.input(:title, :as => :file, :required => true))
82
82
  end)
83
- output_buffer.should have_tag("input[@required]")
83
+ expect(output_buffer).to have_tag("input[@required]")
84
84
  end
85
85
  end
86
86
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'hidden input' do
4
+ RSpec.describe 'hidden input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -22,34 +22,34 @@ describe 'hidden input' do
22
22
  it_should_not_have_a_label
23
23
 
24
24
  it "should generate a input field" do
25
- output_buffer.should have_tag("form li input#post_secret")
26
- output_buffer.should have_tag("form li input#post_secret[@type=\"hidden\"]")
27
- output_buffer.should have_tag("form li input#post_secret[@name=\"post[secret]\"]")
25
+ expect(output_buffer).to have_tag("form li input#post_secret")
26
+ expect(output_buffer).to have_tag("form li input#post_secret[@type=\"hidden\"]")
27
+ expect(output_buffer).to have_tag("form li input#post_secret[@name=\"post[secret]\"]")
28
28
  end
29
29
 
30
30
  it "should get value from the object" do
31
- output_buffer.should have_tag("form li input#post_secret[@type=\"hidden\"][@value=\"1\"]")
31
+ expect(output_buffer).to have_tag("form li input#post_secret[@type=\"hidden\"][@value=\"1\"]")
32
32
  end
33
33
 
34
34
  it "should pass any explicitly specified value - using :input_html options" do
35
- output_buffer.should have_tag("form li input#post_published[@type=\"hidden\"][@value=\"true\"]")
35
+ expect(output_buffer).to have_tag("form li input#post_published[@type=\"hidden\"][@value=\"true\"]")
36
36
  end
37
37
 
38
38
  it "should pass any option specified using :input_html" do
39
- output_buffer.should have_tag("form li input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
39
+ expect(output_buffer).to have_tag("form li input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
40
40
  end
41
41
 
42
42
  it "should not render inline errors" do
43
43
  @errors = double('errors')
44
- @errors.stub(:[]).with(errors_matcher(:secret)).and_return(["foo", "bah"])
45
- @new_post.stub(:errors).and_return(@errors)
44
+ allow(@errors).to receive(:[]).with(errors_matcher(:secret)).and_return(["foo", "bah"])
45
+ allow(@new_post).to receive(:errors).and_return(@errors)
46
46
 
47
47
  concat(semantic_form_for(@new_post) do |builder|
48
48
  concat(builder.input(:secret, :as => :hidden))
49
49
  end)
50
50
 
51
- output_buffer.should_not have_tag("form li p.inline-errors")
52
- output_buffer.should_not have_tag("form li ul.errors")
51
+ expect(output_buffer).not_to have_tag("form li p.inline-errors")
52
+ expect(output_buffer).not_to have_tag("form li ul.errors")
53
53
  end
54
54
 
55
55
  it "should not render inline hints" do
@@ -57,8 +57,8 @@ describe 'hidden input' do
57
57
  concat(builder.input(:secret, :as => :hidden, :hint => "all your base are belong to use"))
58
58
  end)
59
59
 
60
- output_buffer.should_not have_tag("form li p.inline-hints")
61
- output_buffer.should_not have_tag("form li ul.hints")
60
+ expect(output_buffer).not_to have_tag("form li p.inline-hints")
61
+ expect(output_buffer).not_to have_tag("form li ul.hints")
62
62
  end
63
63
 
64
64
  describe "when namespace is provided" do
@@ -99,15 +99,15 @@ describe 'hidden input' do
99
99
  end
100
100
 
101
101
  it 'should index the id of the wrapper' do
102
- output_buffer.should have_tag("li#post_author_attributes_3_name_input")
102
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
103
103
  end
104
104
 
105
105
  it 'should index the id of the select tag' do
106
- output_buffer.should have_tag("input#post_author_attributes_3_name")
106
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
107
107
  end
108
108
 
109
109
  it 'should index the name of the select tag' do
110
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
110
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
111
111
  end
112
112
 
113
113
  end
@@ -118,7 +118,7 @@ describe 'hidden input' do
118
118
  concat(semantic_form_for(@new_post) do |builder|
119
119
  concat(builder.input(:title, :as => :hidden, :required => true))
120
120
  end)
121
- output_buffer.should_not have_tag("input[@required]")
121
+ expect(output_buffer).not_to have_tag("input[@required]")
122
122
  end
123
123
  end
124
124
 
@@ -127,7 +127,7 @@ describe 'hidden input' do
127
127
  concat(semantic_form_for(@new_post) do |builder|
128
128
  concat(builder.input(:title, :as => :hidden, :input_html => {:autofocus => true}))
129
129
  end)
130
- output_buffer.should_not have_tag("input[@autofocus]")
130
+ expect(output_buffer).not_to have_tag("input[@autofocus]")
131
131
  end
132
132
  end
133
133
 
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe "*select: options[:include_blank]" do
4
+ RSpec.describe "*select: options[:include_blank]" do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -9,8 +9,8 @@ describe "*select: options[:include_blank]" do
9
9
  @output_buffer = ''
10
10
  mock_everything
11
11
 
12
- @new_post.stub(:author_id).and_return(nil)
13
- @new_post.stub(:publish_at).and_return(nil)
12
+ allow(@new_post).to receive(:author_id).and_return(nil)
13
+ allow(@new_post).to receive(:publish_at).and_return(nil)
14
14
  end
15
15
 
16
16
  SELECT_INPUT_TYPES = {
@@ -29,7 +29,7 @@ describe "*select: options[:include_blank]" do
29
29
  concat(semantic_form_for(@new_post) do |builder|
30
30
  concat(builder.input(attribute, :as => as))
31
31
  end)
32
- output_buffer.should have_tag("form li select option[@value='']", "")
32
+ expect(output_buffer).to have_tag("form li select option[@value='']", "")
33
33
  end
34
34
 
35
35
  it 'blank value should not be included if the default value specified in config is false' do
@@ -37,7 +37,7 @@ describe "*select: options[:include_blank]" do
37
37
  concat(semantic_form_for(@new_post) do |builder|
38
38
  concat(builder.input(attribute, :as => as))
39
39
  end)
40
- output_buffer.should_not have_tag("form li select option[@value='']", "")
40
+ expect(output_buffer).not_to have_tag("form li select option[@value='']", "")
41
41
  end
42
42
 
43
43
  after do
@@ -50,7 +50,7 @@ describe "*select: options[:include_blank]" do
50
50
  concat(semantic_form_for(@new_post) do |builder|
51
51
  concat(builder.input(attribute, :as => as, :include_blank => false))
52
52
  end)
53
- output_buffer.should_not have_tag("form li select option[@value='']", "")
53
+ expect(output_buffer).not_to have_tag("form li select option[@value='']", "")
54
54
  end
55
55
  end
56
56
 
@@ -59,7 +59,7 @@ describe "*select: options[:include_blank]" do
59
59
  concat(semantic_form_for(@new_post) do |builder|
60
60
  concat(builder.input(attribute, :as => as, :include_blank => true))
61
61
  end)
62
- output_buffer.should have_tag("form li select option[@value='']", "")
62
+ expect(output_buffer).to have_tag("form li select option[@value='']", "")
63
63
  end
64
64
  end
65
65
 
@@ -69,7 +69,7 @@ describe "*select: options[:include_blank]" do
69
69
  concat(semantic_form_for(@new_post) do |builder|
70
70
  concat(builder.input(attribute, :as => as, :include_blank => 'string'))
71
71
  end)
72
- output_buffer.should have_tag("form li select option[@value='']", "string")
72
+ expect(output_buffer).to have_tag("form li select option[@value='']", "string")
73
73
  end
74
74
  end
75
75
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'Formtastic::FormBuilder#label' do
4
+ RSpec.describe 'Formtastic::FormBuilder#label' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -28,7 +28,7 @@ describe 'Formtastic::FormBuilder#label' do
28
28
  ::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => nil } } } }
29
29
  Formtastic::FormBuilder.required_string = default_required_str
30
30
 
31
- output_buffer.scan(required_string).count.should == 1
31
+ expect(output_buffer.scan(required_string).count).to eq(1)
32
32
  end
33
33
  end
34
34
 
@@ -36,7 +36,7 @@ describe 'Formtastic::FormBuilder#label' do
36
36
  concat(semantic_form_for(@new_post) do |builder|
37
37
  builder.input(:title)
38
38
  end)
39
- output_buffer.should have_tag('label', /Title/)
39
+ expect(output_buffer).to have_tag('label', :text => /Title/)
40
40
  end
41
41
 
42
42
  it 'should use i18n instead of the method name when method given as a String' do
@@ -46,7 +46,7 @@ describe 'Formtastic::FormBuilder#label' do
46
46
  builder.input("title")
47
47
  end)
48
48
  ::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => nil } } } }
49
- output_buffer.should have_tag('label', /I18n title/)
49
+ expect(output_buffer).to have_tag('label', :text => /I18n title/)
50
50
  end
51
51
  end
52
52
 
@@ -54,7 +54,7 @@ describe 'Formtastic::FormBuilder#label' do
54
54
  concat(semantic_form_for(@new_post) do |builder|
55
55
  builder.input(:publish_at)
56
56
  end)
57
- output_buffer.should have_tag('label', /Publish at/)
57
+ expect(output_buffer).to have_tag('label', :text => /Publish at/)
58
58
  end
59
59
 
60
60
  describe 'when required is given' do
@@ -62,7 +62,7 @@ describe 'Formtastic::FormBuilder#label' do
62
62
  concat(semantic_form_for(@new_post) do |builder|
63
63
  builder.input(:title, :required => true)
64
64
  end)
65
- output_buffer.should have_tag('label abbr', '*')
65
+ expect(output_buffer).to have_tag('label abbr', '*')
66
66
  end
67
67
  end
68
68
 
@@ -73,7 +73,7 @@ describe 'Formtastic::FormBuilder#label' do
73
73
  concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :member_value => :to_s, :member_label => proc {|f| ('Label_%s' % [f])}))
74
74
  end)
75
75
  end
76
- output_buffer.should have_tag('form li fieldset ol li label', /Label_[abc]/, :count => 3)
76
+ expect(output_buffer).to have_tag('form li fieldset ol li label', :text => /Label_[abc]/, :count => 3)
77
77
  end
78
78
 
79
79
  it 'should use a supplied value_method for simple collections' do
@@ -82,9 +82,9 @@ describe 'Formtastic::FormBuilder#label' do
82
82
  concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :member_value => proc {|f| ('Value_%s' % [f.to_s])}))
83
83
  end)
84
84
  end
85
- output_buffer.should have_tag('form li fieldset ol li label input[value="Value_a"]')
86
- output_buffer.should have_tag('form li fieldset ol li label input[value="Value_b"]')
87
- output_buffer.should have_tag('form li fieldset ol li label input[value="Value_c"]')
85
+ expect(output_buffer).to have_tag('form li fieldset ol li label input[value="Value_a"]')
86
+ expect(output_buffer).to have_tag('form li fieldset ol li label input[value="Value_b"]')
87
+ expect(output_buffer).to have_tag('form li fieldset ol li label input[value="Value_c"]')
88
88
  end
89
89
  end
90
90
 
@@ -93,38 +93,38 @@ describe 'Formtastic::FormBuilder#label' do
93
93
  concat(semantic_form_for(@new_post) do |builder|
94
94
  builder.input(:title, :label => 'My label')
95
95
  end)
96
- output_buffer.should have_tag('label', /My label/)
96
+ expect(output_buffer).to have_tag('label', :text => /My label/)
97
97
  end
98
98
 
99
99
  it 'should allow the text to be given as label option for date fields' do
100
100
  concat(semantic_form_for(@new_post) do |builder|
101
101
  builder.input(:publish_at, :label => 'My other label')
102
102
  end)
103
- output_buffer.should have_tag('label', /My other label/)
103
+ expect(output_buffer).to have_tag('label', :text => /My other label/)
104
104
  end
105
105
 
106
106
  it 'should return nil if label is false' do
107
107
  concat(semantic_form_for(@new_post) do |builder|
108
108
  builder.input(:title, :label => false)
109
109
  end)
110
- output_buffer.should_not have_tag('label')
111
- output_buffer.should_not include(">")
110
+ expect(output_buffer).not_to have_tag('label')
111
+ expect(output_buffer).not_to include(">")
112
112
  end
113
113
 
114
114
  it 'should return nil if label is false for timeish fragments' do
115
115
  concat(semantic_form_for(@new_post) do |builder|
116
116
  builder.input(:title, :as => :time_select, :label => false)
117
117
  end)
118
- output_buffer.should_not have_tag('li.time > label')
119
- output_buffer.should_not include(">")
118
+ expect(output_buffer).not_to have_tag('li.time > label')
119
+ expect(output_buffer).not_to include(">")
120
120
  end
121
121
 
122
122
  it 'should html escape the label string by default' do
123
123
  concat(semantic_form_for(@new_post) do |builder|
124
124
  builder.input(:title, :label => '<b>My label</b>')
125
125
  end)
126
- output_buffer.should include('&lt;b&gt;')
127
- output_buffer.should_not include('<b>')
126
+ expect(output_buffer).to include('&lt;b&gt;')
127
+ expect(output_buffer).not_to include('<b>')
128
128
  end
129
129
 
130
130
  it 'should not html escape the label if configured that way' do
@@ -132,7 +132,7 @@ describe 'Formtastic::FormBuilder#label' do
132
132
  concat(semantic_form_for(@new_post) do |builder|
133
133
  builder.input(:title, :label => '<b>My label</b>')
134
134
  end)
135
- output_buffer.should have_tag("label b", "My label")
135
+ expect(output_buffer).to have_tag("label b", :text => "My label")
136
136
  end
137
137
 
138
138
  it 'should not html escape the label string for html_safe strings' do
@@ -140,7 +140,7 @@ describe 'Formtastic::FormBuilder#label' do
140
140
  concat(semantic_form_for(@new_post) do |builder|
141
141
  builder.input(:title, :label => '<b>My label</b>'.html_safe)
142
142
  end)
143
- output_buffer.should have_tag('label b')
143
+ expect(output_buffer).to have_tag('label b')
144
144
  end
145
145
 
146
146
  end