1
1
require 'test_helper'
2
2
3
- class CarmenViewHelperTest < MiniTest ::Unit :: TestCase
3
+ class CarmenViewHelperTest < MiniTest ::Test
4
4
include ActionView ::Helpers ::FormOptionsHelper
5
5
include ActionView ::Helpers ::FormTagHelper
6
- include ActionDispatch ::Assertions ::SelectorAssertions
6
+
7
+ if ::Rails . const_defined? ( :Dom )
8
+ include ::Rails ::Dom ::Testing ::Assertions ::SelectorAssertions
9
+ else
10
+ include ActionDispatch ::Assertions ::SelectorAssertions
11
+ end
7
12
8
13
def setup
9
14
@object = OpenStruct . new
15
+
10
16
def @object . to_s ; 'object' ; end
11
17
end
12
18
@@ -27,6 +33,10 @@ def test_basic_country_select
27
33
assert_equal_markup ( expected , html )
28
34
end
29
35
36
+ def document_root_element
37
+ Nokogiri . parse ( @html )
38
+ end
39
+
30
40
def test_country_selected_value
31
41
@html = country_select ( :object , :country_code , :selected => 'OC' )
32
42
assert_select ( 'option[selected="selected"][value="OC"]' )
@@ -123,6 +133,7 @@ def test_basic_subregion_select
123
133
expected = <<-HTML
124
134
< select id ="object_subregion_code " name ="object[subregion_code] ">
125
135
< option value ="AO "> Airstrip One</ option >
136
+ < option value ="AT "> Airstrip-Two</ option >
126
137
</ select >
127
138
HTML
128
139
@@ -135,6 +146,7 @@ def test_subregion_select_using_parent_code
135
146
expected = <<-HTML
136
147
< select id ="object_subregion_code " name ="object[subregion_code] ">
137
148
< option value ="AO "> Airstrip One</ option >
149
+ < option value ="AT "> Airstrip-Two</ option >
138
150
</ select >
139
151
HTML
140
152
@@ -181,6 +193,7 @@ def test_basic_subregion_select_tag
181
193
expected = <<-HTML
182
194
< select id ="subregion_code " name ="subregion_code ">
183
195
< option value ="AO "> Airstrip One</ option >
196
+ < option value ="AT "> Airstrip-Two</ option >
184
197
</ select >
185
198
HTML
186
199
@@ -196,6 +209,7 @@ def test_subregion_select_tag_with_priority
196
209
< option value ="AO "> Airstrip One</ option >
197
210
< option disabled > -------------</ option >
198
211
< option value ="AO "> Airstrip One</ option >
212
+ < option value ="AT "> Airstrip-Two</ option >
199
213
</ select >
200
214
HTML
201
215
@@ -210,6 +224,7 @@ def test_subregion_select_tag_with_prompt
210
224
< select id ="subregion_code " name ="subregion_code ">
211
225
< option value =""> Please select</ option >
212
226
< option value ="AO "> Airstrip One</ option >
227
+ < option value ="AT "> Airstrip-Two</ option >
213
228
</ select >
214
229
HTML
215
230
@@ -252,7 +267,7 @@ def test_region_options_for_select_with_array_of_regions_and_priority
252
267
end
253
268
254
269
def test_form_builder_country_select
255
- form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } , lambda { } )
270
+ form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } )
256
271
257
272
html = form . country_select ( 'attribute_name' )
258
273
expected = <<-HTML
@@ -268,14 +283,14 @@ def test_form_builder_country_select
268
283
269
284
def test_form_builder_selected_country
270
285
@object . country_code = 'OC'
271
- form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } , lambda { } )
286
+ form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } )
272
287
@html = form . country_select ( 'country_code' )
273
288
274
289
assert_select ( 'option[selected="selected"][value="OC"]' )
275
290
end
276
291
277
292
def test_form_builder_country_select_deprecated_api
278
- form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } , lambda { } )
293
+ form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } )
279
294
280
295
html = form . country_select ( 'attribute_name' , [ 'ES' ] )
281
296
expected = <<-HTML
@@ -292,11 +307,12 @@ def test_form_builder_country_select_deprecated_api
292
307
end
293
308
294
309
def test_form_builder_subregion_select
295
- form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } , lambda { } )
310
+ form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } )
296
311
html = form . subregion_select ( :subregion_code , 'OC' )
297
312
expected = <<-HTML
298
313
< select id ="object_subregion_code " name ="object[subregion_code] ">
299
314
< option value ="AO "> Airstrip One</ option >
315
+ < option value ="AT "> Airstrip-Two</ option >
300
316
</ select >
301
317
HTML
302
318
@@ -305,7 +321,7 @@ def test_form_builder_subregion_select
305
321
306
322
def test_form_builder_selected_subregion
307
323
@object . subregion_code = 'AO'
308
- form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } , lambda { } )
324
+ form = ActionView ::Helpers ::FormBuilder . new ( :object , @object , self , { } )
309
325
@html = form . subregion_select ( :subregion_code , 'OC' )
310
326
311
327
assert_select ( 'option[selected="selected"][value="AO"]' )
0 commit comments