formtastic 3.1.5 → 4.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitattributes +1 -0
- data/.gitignore +3 -2
- data/.travis.yml +28 -40
- data/CHANGELOG.md +49 -0
- data/DEPRECATIONS +1 -1
- data/Gemfile.lock +104 -0
- data/README.md +628 -629
- data/Rakefile +20 -1
- data/app/assets/stylesheets/formtastic.css +1 -1
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +8 -14
- data/gemfiles/rails_5.2/Gemfile +5 -0
- data/gemfiles/rails_6.0/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +13 -0
- data/lib/formtastic.rb +5 -11
- data/lib/formtastic/actions.rb +6 -3
- data/lib/formtastic/deprecation.rb +1 -38
- data/lib/formtastic/engine.rb +3 -1
- data/lib/formtastic/form_builder.rb +8 -24
- data/lib/formtastic/helpers/action_helper.rb +1 -48
- data/lib/formtastic/helpers/errors_helper.rb +2 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +7 -3
- data/lib/formtastic/helpers/input_helper.rb +18 -76
- data/lib/formtastic/helpers/inputs_helper.rb +12 -3
- data/lib/formtastic/i18n.rb +1 -1
- data/lib/formtastic/inputs.rb +32 -29
- data/lib/formtastic/inputs/base/collections.rb +1 -5
- data/lib/formtastic/inputs/base/errors.rb +4 -4
- data/lib/formtastic/inputs/base/hints.rb +1 -1
- data/lib/formtastic/inputs/base/timeish.rb +5 -1
- data/lib/formtastic/inputs/base/validations.rb +19 -9
- data/lib/formtastic/inputs/check_boxes_input.rb +3 -3
- data/lib/formtastic/inputs/color_input.rb +0 -1
- data/lib/formtastic/inputs/select_input.rb +1 -1
- data/lib/formtastic/localizer.rb +5 -7
- data/lib/formtastic/version.rb +1 -1
- data/lib/generators/templates/formtastic.rb +4 -6
- data/script/integration-template.rb +71 -0
- data/script/integration.sh +19 -0
- data/spec/action_class_finder_spec.rb +1 -1
- data/spec/actions/button_action_spec.rb +8 -8
- data/spec/actions/generic_action_spec.rb +60 -60
- data/spec/actions/input_action_spec.rb +7 -7
- data/spec/actions/link_action_spec.rb +10 -10
- data/spec/builder/custom_builder_spec.rb +36 -20
- data/spec/builder/error_proc_spec.rb +4 -4
- data/spec/builder/semantic_fields_for_spec.rb +27 -27
- data/spec/generators/formtastic/form/form_generator_spec.rb +25 -25
- data/spec/generators/formtastic/input/input_generator_spec.rb +31 -31
- data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
- data/spec/helpers/action_helper_spec.rb +328 -10
- data/spec/helpers/actions_helper_spec.rb +17 -17
- data/spec/helpers/form_helper_spec.rb +33 -33
- data/spec/helpers/input_helper_spec.rb +975 -2
- data/spec/helpers/inputs_helper_spec.rb +120 -105
- data/spec/helpers/reflection_helper_spec.rb +3 -3
- data/spec/helpers/semantic_errors_helper_spec.rb +22 -22
- data/spec/i18n_spec.rb +26 -26
- data/spec/input_class_finder_spec.rb +1 -1
- data/spec/inputs/base/collections_spec.rb +6 -6
- data/spec/inputs/base/validations_spec.rb +157 -19
- data/spec/inputs/boolean_input_spec.rb +55 -55
- data/spec/inputs/check_boxes_input_spec.rb +96 -95
- data/spec/inputs/color_input_spec.rb +51 -63
- data/spec/inputs/country_input_spec.rb +20 -20
- data/spec/inputs/custom_input_spec.rb +2 -6
- data/spec/inputs/datalist_input_spec.rb +1 -1
- data/spec/inputs/date_picker_input_spec.rb +42 -42
- data/spec/inputs/date_select_input_spec.rb +51 -37
- data/spec/inputs/datetime_picker_input_spec.rb +46 -46
- data/spec/inputs/datetime_select_input_spec.rb +53 -37
- data/spec/inputs/email_input_spec.rb +5 -5
- data/spec/inputs/file_input_spec.rb +6 -6
- data/spec/inputs/hidden_input_spec.rb +18 -18
- data/spec/inputs/include_blank_spec.rb +8 -8
- data/spec/inputs/label_spec.rb +20 -20
- data/spec/inputs/number_input_spec.rb +112 -112
- data/spec/inputs/password_input_spec.rb +5 -5
- data/spec/inputs/phone_input_spec.rb +5 -5
- data/spec/inputs/placeholder_spec.rb +5 -5
- data/spec/inputs/radio_input_spec.rb +63 -65
- data/spec/inputs/range_input_spec.rb +66 -66
- data/spec/inputs/readonly_spec.rb +4 -4
- data/spec/inputs/search_input_spec.rb +5 -5
- data/spec/inputs/select_input_spec.rb +92 -96
- data/spec/inputs/string_input_spec.rb +23 -23
- data/spec/inputs/text_input_spec.rb +16 -16
- data/spec/inputs/time_picker_input_spec.rb +43 -43
- data/spec/inputs/time_select_input_spec.rb +67 -54
- data/spec/inputs/time_zone_input_spec.rb +19 -19
- data/spec/inputs/url_input_spec.rb +5 -5
- data/spec/inputs/with_options_spec.rb +7 -7
- data/spec/localizer_spec.rb +17 -17
- data/spec/namespaced_class_finder_spec.rb +2 -2
- data/spec/schema.rb +21 -0
- data/spec/spec_helper.rb +163 -223
- data/spec/support/custom_macros.rb +72 -75
- data/spec/support/shared_examples.rb +0 -1301
- data/spec/support/test_environment.rb +23 -9
- metadata +33 -123
- data/Appraisals +0 -43
- data/CHANGELOG +0 -54
- data/gemfiles/rails_3.2.gemfile +0 -9
- data/gemfiles/rails_4.0.4.gemfile +0 -8
- data/gemfiles/rails_4.1.gemfile +0 -8
- data/gemfiles/rails_4.2.gemfile +0 -8
- data/gemfiles/rails_4.gemfile +0 -8
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_edge.gemfile +0 -15
- data/lib/formtastic/util.rb +0 -57
- data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
- data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
- data/spec/util_spec.rb +0 -66
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'time select input' do
|
4
|
+
RSpec.describe 'time select input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -24,42 +24,42 @@ describe 'time select input' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should not have hidden inputs for day, month and year' do
|
27
|
-
output_buffer.
|
28
|
-
output_buffer.
|
29
|
-
output_buffer.
|
27
|
+
expect(output_buffer).not_to have_tag('input#post_publish_at_1i')
|
28
|
+
expect(output_buffer).not_to have_tag('input#post_publish_at_2i')
|
29
|
+
expect(output_buffer).not_to have_tag('input#post_publish_at_3i')
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should have an input for hour and minute' do
|
33
|
-
output_buffer.
|
34
|
-
output_buffer.
|
33
|
+
expect(output_buffer).to have_tag('select#post_publish_at_4i')
|
34
|
+
expect(output_buffer).to have_tag('select#post_publish_at_5i')
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "with :ignore_date => false" do
|
40
40
|
before do
|
41
|
-
@new_post.
|
41
|
+
allow(@new_post).to receive(:publish_at).and_return(Time.parse('2010-11-07'))
|
42
42
|
concat(semantic_form_for(@new_post) do |builder|
|
43
43
|
concat(builder.input(:publish_at, :as => :time_select, :ignore_date => false))
|
44
44
|
end)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'should have a hidden input for day, month and year' do
|
48
|
-
output_buffer.
|
49
|
-
output_buffer.
|
50
|
-
output_buffer.
|
51
|
-
output_buffer.
|
52
|
-
output_buffer.
|
53
|
-
output_buffer.
|
48
|
+
expect(output_buffer).to have_tag('input#post_publish_at_1i')
|
49
|
+
expect(output_buffer).to have_tag('input#post_publish_at_2i')
|
50
|
+
expect(output_buffer).to have_tag('input#post_publish_at_3i')
|
51
|
+
expect(output_buffer).to have_tag('input#post_publish_at_1i[@value="2010"]')
|
52
|
+
expect(output_buffer).to have_tag('input#post_publish_at_2i[@value="11"]')
|
53
|
+
expect(output_buffer).to have_tag('input#post_publish_at_3i[@value="7"]')
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should have an select for hour and minute' do
|
57
|
-
output_buffer.
|
58
|
-
output_buffer.
|
57
|
+
expect(output_buffer).to have_tag('select#post_publish_at_4i')
|
58
|
+
expect(output_buffer).to have_tag('select#post_publish_at_5i')
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should associate the legend label with the hour select' do
|
62
|
-
output_buffer.
|
62
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset legend.label label[@for="post_publish_at_4i"]')
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
@@ -80,26 +80,26 @@ describe 'time select input' do
|
|
80
80
|
it_should_apply_error_logic_for_input_type(:time_select)
|
81
81
|
|
82
82
|
it 'should have a legend and label with the label text inside the fieldset' do
|
83
|
-
output_buffer.
|
83
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset legend.label label', :text => /Publish at/)
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'should associate the legend label with the first select' do
|
87
|
-
output_buffer.
|
87
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset legend.label label[@for="post_publish_at_4i"]')
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'should have an ordered list of two items inside the fieldset' do
|
91
|
-
output_buffer.
|
92
|
-
output_buffer.
|
91
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol.fragments-group')
|
92
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li.fragment', :count => 2)
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'should have five labels for hour and minute' do
|
96
|
-
output_buffer.
|
97
|
-
output_buffer.
|
98
|
-
output_buffer.
|
96
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :count => 2)
|
97
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => /hour/i)
|
98
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => /minute/i)
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should have two selects for hour and minute' do
|
102
|
-
output_buffer.
|
102
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li', :count => 2)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -111,20 +111,20 @@ describe 'time select input' do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'should have five labels for hour and minute' do
|
114
|
-
output_buffer.
|
115
|
-
output_buffer.
|
116
|
-
output_buffer.
|
117
|
-
output_buffer.
|
114
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :count => 3)
|
115
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => /hour/i)
|
116
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => /minute/i)
|
117
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => /second/i)
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should have three selects for hour, minute and seconds' do
|
121
|
-
output_buffer.
|
121
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li', :count => 3)
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'should generate a sanitized label and matching ids for attribute' do
|
125
125
|
4.upto(6) do |i|
|
126
|
-
output_buffer.
|
127
|
-
output_buffer.
|
126
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label[@for='post_publish_at_#{i}i']")
|
127
|
+
expect(output_buffer).to have_tag("form li fieldset ol li #post_publish_at_#{i}i")
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
@@ -138,9 +138,9 @@ describe 'time select input' do
|
|
138
138
|
concat(semantic_form_for(@new_post) do |builder|
|
139
139
|
concat(builder.input(:created_at, :as => :time_select, :include_seconds => true, :labels => { field => "another #{field} label" }))
|
140
140
|
end)
|
141
|
-
output_buffer.
|
141
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :count => fields.length)
|
142
142
|
fields.each do |f|
|
143
|
-
output_buffer.
|
143
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => f == field ? /another #{f} label/i : /#{f}/i)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -149,9 +149,9 @@ describe 'time select input' do
|
|
149
149
|
concat(semantic_form_for(@new_post) do |builder|
|
150
150
|
concat(builder.input(:created_at, :as => :time_select, :include_seconds => true, :labels => { field => "" }))
|
151
151
|
end)
|
152
|
-
output_buffer.
|
152
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :count => fields.length-1)
|
153
153
|
fields.each do |f|
|
154
|
-
output_buffer.
|
154
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => /#{f}/i) unless field == f
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
@@ -160,9 +160,9 @@ describe 'time select input' do
|
|
160
160
|
concat(semantic_form_for(@new_post) do |builder|
|
161
161
|
concat(builder.input(:created_at, :as => :time_select, :include_seconds => true, :labels => { field => false }))
|
162
162
|
end)
|
163
|
-
output_buffer.
|
163
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :count => fields.length-1)
|
164
164
|
fields.each do |f|
|
165
|
-
output_buffer.
|
165
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :text => /#{f}/i) unless field == f
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
@@ -171,7 +171,7 @@ describe 'time select input' do
|
|
171
171
|
concat(semantic_form_for(@new_post) do |builder|
|
172
172
|
concat(builder.input(:created_at, :as => :time_select, :include_seconds => true, :labels => { field => false }))
|
173
173
|
end)
|
174
|
-
output_buffer.
|
174
|
+
expect(output_buffer).not_to include(">")
|
175
175
|
end
|
176
176
|
|
177
177
|
end
|
@@ -181,7 +181,20 @@ describe 'time select input' do
|
|
181
181
|
concat(semantic_form_for(@new_post) do |builder|
|
182
182
|
concat(builder.input(:created_at, :as => :time_select, :include_seconds => true, :labels => false))
|
183
183
|
end)
|
184
|
-
output_buffer.
|
184
|
+
expect(output_buffer).to have_tag('form li.time_select fieldset ol li label', :count => 0)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe ":selected option for setting a value" do
|
189
|
+
it "should set the selected value for the form" do
|
190
|
+
concat(
|
191
|
+
semantic_form_for(@new_post) do |f|
|
192
|
+
concat(f.input(:created_at, :as => :datetime_select, :selected => DateTime.new(2018, 10, 4, 12, 00)))
|
193
|
+
end
|
194
|
+
)
|
195
|
+
|
196
|
+
expect(output_buffer).to have_tag "option[value='12'][selected='selected']"
|
197
|
+
expect(output_buffer).to have_tag "option[value='00'][selected='selected']"
|
185
198
|
end
|
186
199
|
end
|
187
200
|
|
@@ -193,9 +206,9 @@ describe 'time select input' do
|
|
193
206
|
end
|
194
207
|
|
195
208
|
it 'should have a tag matching the namespace' do
|
196
|
-
output_buffer.
|
197
|
-
output_buffer.
|
198
|
-
output_buffer.
|
209
|
+
expect(output_buffer).to have_tag('#form2_post_publish_at_input')
|
210
|
+
expect(output_buffer).to have_tag('#form2_post_publish_at_4i')
|
211
|
+
expect(output_buffer).to have_tag('#form2_post_publish_at_5i')
|
199
212
|
end
|
200
213
|
end
|
201
214
|
|
@@ -205,7 +218,7 @@ describe 'time select input' do
|
|
205
218
|
concat(semantic_form_for(@new_post) do |builder|
|
206
219
|
concat(builder.input(:title, :as => :time_select, :required => true))
|
207
220
|
end)
|
208
|
-
output_buffer.
|
221
|
+
expect(output_buffer).to have_tag("select[@required]", :count => 2)
|
209
222
|
end
|
210
223
|
end
|
211
224
|
end
|
@@ -221,23 +234,23 @@ describe 'time select input' do
|
|
221
234
|
end
|
222
235
|
|
223
236
|
it 'should index the id of the wrapper' do
|
224
|
-
output_buffer.
|
237
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
|
225
238
|
end
|
226
239
|
|
227
240
|
it 'should index the id of the select tag' do
|
228
|
-
output_buffer.
|
229
|
-
output_buffer.
|
230
|
-
output_buffer.
|
231
|
-
output_buffer.
|
232
|
-
output_buffer.
|
241
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at_1i")
|
242
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at_2i")
|
243
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at_3i")
|
244
|
+
expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_4i")
|
245
|
+
expect(output_buffer).to have_tag("select#post_author_attributes_3_created_at_5i")
|
233
246
|
end
|
234
247
|
|
235
248
|
it 'should index the name of the select tag' do
|
236
|
-
output_buffer.
|
237
|
-
output_buffer.
|
238
|
-
output_buffer.
|
239
|
-
output_buffer.
|
240
|
-
output_buffer.
|
249
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at(1i)]']")
|
250
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at(2i)]']")
|
251
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at(3i)]']")
|
252
|
+
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(4i)]']")
|
253
|
+
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][created_at(5i)]']")
|
241
254
|
end
|
242
255
|
|
243
256
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'time_zone input' do
|
4
|
+
RSpec.describe 'time_zone input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -20,22 +20,22 @@ describe 'time_zone input' do
|
|
20
20
|
it_should_apply_error_logic_for_input_type(:time_zone)
|
21
21
|
|
22
22
|
it 'should generate a label for the input' do
|
23
|
-
output_buffer.
|
24
|
-
output_buffer.
|
25
|
-
output_buffer.
|
23
|
+
expect(output_buffer).to have_tag('form li label')
|
24
|
+
expect(output_buffer).to have_tag('form li label[@for="post_time_zone"]')
|
25
|
+
expect(output_buffer).to have_tag('form li label', :text => /Time zone/)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should generate a select" do
|
29
|
-
output_buffer.
|
30
|
-
output_buffer.
|
31
|
-
output_buffer.
|
29
|
+
expect(output_buffer).to have_tag("form li select")
|
30
|
+
expect(output_buffer).to have_tag("form li select#post_time_zone")
|
31
|
+
expect(output_buffer).to have_tag("form li select[@name=\"post[time_zone]\"]")
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should use input_html to style inputs' do
|
35
35
|
concat(semantic_form_for(@new_post) do |builder|
|
36
36
|
concat(builder.input(:time_zone, :input_html => { :class => 'myclass' }))
|
37
37
|
end)
|
38
|
-
output_buffer.
|
38
|
+
expect(output_buffer).to have_tag("form li select.myclass")
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "when namespace is provided" do
|
@@ -69,37 +69,37 @@ describe 'time_zone input' do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should index the id of the wrapper' do
|
72
|
-
output_buffer.
|
72
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should index the id of the select tag' do
|
76
|
-
output_buffer.
|
76
|
+
expect(output_buffer).to have_tag("select#post_author_attributes_3_name")
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should index the name of the select tag' do
|
80
|
-
output_buffer.
|
80
|
+
expect(output_buffer).to have_tag("select[@name='post[author_attributes][3][name]']")
|
81
81
|
end
|
82
82
|
|
83
83
|
end
|
84
84
|
|
85
85
|
|
86
86
|
describe 'when no object is given' do
|
87
|
-
before(:
|
87
|
+
before(:example) do
|
88
88
|
concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
|
89
89
|
concat(builder.input(:time_zone, :as => :time_zone))
|
90
90
|
end)
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'should generate labels' do
|
94
|
-
output_buffer.
|
95
|
-
output_buffer.
|
96
|
-
output_buffer.
|
94
|
+
expect(output_buffer).to have_tag('form li label')
|
95
|
+
expect(output_buffer).to have_tag('form li label[@for="project_time_zone"]')
|
96
|
+
expect(output_buffer).to have_tag('form li label', :text => /Time zone/)
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'should generate select inputs' do
|
100
|
-
output_buffer.
|
101
|
-
output_buffer.
|
102
|
-
output_buffer.
|
100
|
+
expect(output_buffer).to have_tag("form li select")
|
101
|
+
expect(output_buffer).to have_tag("form li select#project_time_zone")
|
102
|
+
expect(output_buffer).to have_tag("form li select[@name=\"project[time_zone]\"]")
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -109,7 +109,7 @@ describe 'time_zone input' do
|
|
109
109
|
concat(semantic_form_for(@new_post) do |builder|
|
110
110
|
concat(builder.input(:title, :as => :time_zone, :required => true))
|
111
111
|
end)
|
112
|
-
output_buffer.
|
112
|
+
expect(output_buffer).to have_tag("select[@required]")
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'url input' do
|
4
|
+
RSpec.describe 'url input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -56,15 +56,15 @@ describe 'url input' do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should index the id of the wrapper' do
|
59
|
-
output_buffer.
|
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.
|
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.
|
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 'url input' do
|
|
76
76
|
concat(semantic_form_for(@new_post) do |builder|
|
77
77
|
concat(builder.input(:title, :as => :url, :required => true))
|
78
78
|
end)
|
79
|
-
output_buffer.
|
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 'string input' do
|
4
|
+
RSpec.describe 'string input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -21,23 +21,23 @@ describe 'string input' do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should have extra class on title" do
|
24
|
-
output_buffer.
|
24
|
+
expect(output_buffer).to have_tag("form li#post_title_input.extra")
|
25
25
|
end
|
26
26
|
it "should have title as string" do
|
27
|
-
output_buffer.
|
27
|
+
expect(output_buffer).to have_tag("form li#post_title_input.string")
|
28
28
|
end
|
29
29
|
it "should not have title as radio" do
|
30
|
-
output_buffer.
|
30
|
+
expect(output_buffer).not_to have_tag("form li#post_title_input.radio")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should have extra class on author" do
|
34
|
-
output_buffer.
|
34
|
+
expect(output_buffer).to have_tag("form li#post_author_input.extra")
|
35
35
|
end
|
36
36
|
it "should not have author as string" do
|
37
|
-
output_buffer.
|
37
|
+
expect(output_buffer).not_to have_tag("form li#post_author_input.string")
|
38
38
|
end
|
39
39
|
it "should have author as radio" do
|
40
|
-
output_buffer.
|
40
|
+
expect(output_buffer).to have_tag("form li#post_author_input.radio")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
data/spec/localizer_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'Formtastic::Localizer' do
|
4
|
+
RSpec.describe 'Formtastic::Localizer' do
|
5
5
|
describe "Cache" do
|
6
6
|
before do
|
7
7
|
@cache = Formtastic::Localizer::Cache.new
|
@@ -11,27 +11,27 @@ describe 'Formtastic::Localizer' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should get value" do
|
14
|
-
@cache.get(@key).
|
15
|
-
@cache.get(@undefined_key).
|
14
|
+
expect(@cache.get(@key)).to eq('value')
|
15
|
+
expect(@cache.get(@undefined_key)).to be_nil
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should check if key exists?" do
|
19
|
-
@cache.has_key?(@key).
|
20
|
-
@cache.has_key?(@undefined_key).
|
19
|
+
expect(@cache.has_key?(@key)).to be_truthy
|
20
|
+
expect(@cache.has_key?(@undefined_key)).to be_falsey
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should set a key" do
|
24
24
|
@cache.set(['model', 'name2'], 'value2')
|
25
|
-
@cache.get(['model', 'name2']).
|
25
|
+
expect(@cache.get(['model', 'name2'])).to eq('value2')
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return hash" do
|
29
|
-
@cache.cache.
|
29
|
+
expect(@cache.cache).to be_an_instance_of(Hash)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should clear the cache" do
|
33
33
|
@cache.clear!
|
34
|
-
@cache.get(@key).
|
34
|
+
expect(@cache.get(@key)).to be_nil
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -53,11 +53,11 @@ describe 'Formtastic::Localizer' do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should be defined" do
|
56
|
-
|
56
|
+
expect { Formtastic::Localizer }.not_to raise_error
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should have a cache" do
|
60
|
-
Formtastic::Localizer.cache.
|
60
|
+
expect(Formtastic::Localizer.cache).to be_an_instance_of(Formtastic::Localizer::Cache)
|
61
61
|
end
|
62
62
|
|
63
63
|
describe "localize" do
|
@@ -75,19 +75,19 @@ describe 'Formtastic::Localizer' do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should translate key with i18n" do
|
78
|
-
@localizer.localize(:name, :name, :label).
|
78
|
+
expect(@localizer.localize(:name, :name, :label)).to eq('POST.NAME')
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "with caching" do
|
82
82
|
it "should not update translation when stored translations change" do
|
83
83
|
with_config :i18n_cache_lookups, true do
|
84
|
-
@localizer.localize(:name, :name, :label).
|
84
|
+
expect(@localizer.localize(:name, :name, :label)).to eq('POST.NAME')
|
85
85
|
store_post_translations('POST.NEW_NAME')
|
86
86
|
|
87
|
-
@localizer.localize(:name, :name, :label).
|
87
|
+
expect(@localizer.localize(:name, :name, :label)).to eq('POST.NAME')
|
88
88
|
|
89
89
|
Formtastic::Localizer.cache.clear!
|
90
|
-
@localizer.localize(:name, :name, :label).
|
90
|
+
expect(@localizer.localize(:name, :name, :label)).to eq('POST.NEW_NAME')
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -95,9 +95,9 @@ describe 'Formtastic::Localizer' do
|
|
95
95
|
describe "without caching" do
|
96
96
|
it "should update translation when stored translations change" do
|
97
97
|
with_config :i18n_cache_lookups, false do
|
98
|
-
@localizer.localize(:name, :name, :label).
|
98
|
+
expect(@localizer.localize(:name, :name, :label)).to eq('POST.NAME')
|
99
99
|
store_post_translations('POST.NEW_NAME')
|
100
|
-
@localizer.localize(:name, :name, :label).
|
100
|
+
expect(@localizer.localize(:name, :name, :label)).to eq('POST.NEW_NAME')
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -120,7 +120,7 @@ describe 'Formtastic::Localizer' do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should translate custom key with i18n" do
|
123
|
-
@localizer.localize(:name, :name, :label).
|
123
|
+
expect(@localizer.localize(:name, :name, :label)).to eq('MESSAGE.NAME')
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|