Skip to content

Commit 6f866e0

Browse files
Fix country_select tests looking for separator option
They changed to use an `<hr>` element now rather than a disabled option with `-` as separator. countries/country_select#229
1 parent 651f119 commit 6f866e0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/inputs/country_input_test.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,31 @@
33
require 'test_helper'
44

55
class CountryInputTest < ActionView::TestCase
6+
COUNTRY_SELECT_SEPARATOR =
7+
if Gem::Version.new(CountrySelect::VERSION) >= Gem::Version.new("11.0.0")
8+
"hr"
9+
else
10+
'option[value="---------------"][disabled=disabled]'
11+
end
12+
613
test 'input generates a country select field' do
714
with_input_for @user, :country, :country
815
assert_select 'select#user_country'
916
assert_select 'select option[value=BR]', 'Brazil'
1017
assert_no_select 'select option[value=""][disabled=disabled]'
18+
assert_no_select "select #{COUNTRY_SELECT_SEPARATOR}"
1119
end
1220

1321
test 'input generates a country select with SimpleForm default' do
1422
swap SimpleForm, country_priority: [ 'Brazil' ] do
1523
with_input_for @user, :country, :country
16-
assert_select 'select option[value="BR"] + option[value="---------------"][disabled=disabled]'
24+
assert_select %(select option[value="BR"] + #{COUNTRY_SELECT_SEPARATOR})
1725
end
1826
end
1927

2028
test 'input generates a country select using options priority' do
2129
with_input_for @user, :country, :country, priority: [ 'Ukraine' ]
22-
assert_select 'select option[value="UA"] + option[value="---------------"][disabled=disabled]'
30+
assert_select %(select option[value="UA"] + #{COUNTRY_SELECT_SEPARATOR})
2331
end
2432

2533
test 'input does generate select element with required html attribute' do

0 commit comments

Comments
 (0)