From 71a95b95fa9b30acd1c4ab57c7cd0ad473c4b14d Mon Sep 17 00:00:00 2001 From: Felipe Renan Date: Fri, 3 Aug 2018 21:09:43 -0300 Subject: [PATCH] Fix tests that are broken after nokogiri 1.8.4 I'm not sure why it have happened, but after nokogiri 1.8.4 these tests started to break. I'm updating the match syntax to let it green again. See more about it in the link below: https://edgeguides.rubyonrails.org/4_2_release_notes.html#assert-select --- test/form_builder/input_field_test.rb | 6 +++--- test/inputs/string_input_test.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/form_builder/input_field_test.rb b/test/form_builder/input_field_test.rb index 17a29493..f563d15f 100644 --- a/test/form_builder/input_field_test.rb +++ b/test/form_builder/input_field_test.rb @@ -79,13 +79,13 @@ class InputFieldTest < ActionView::TestCase test 'builder input_field infers pattern from attributes' do with_input_field_for @other_validating_user, :country, as: :string, pattern: true - assert_select 'input[pattern="\w+"]' + assert_select "input:match('pattern', ?)", /\w+/ end test 'builder input_field accepts custom pattern' do with_input_field_for @other_validating_user, :country, as: :string, pattern: '\d+' - assert_select 'input[pattern="\d+"]' + assert_select "input:match('pattern', ?)", /\\d+/ end test 'builder input_field uses readonly component' do @@ -132,7 +132,7 @@ class InputFieldTest < ActionView::TestCase swap_wrapper :default, custom_wrapper_with_html5_components do with_input_field_for @user, :name, pattern: '\w+' - assert_select 'input[pattern="\w+"]' + assert_select "input:match('pattern', ?)", /\w+/ end end diff --git a/test/inputs/string_input_test.rb b/test/inputs/string_input_test.rb index 417b3129..13164eca 100644 --- a/test/inputs/string_input_test.rb +++ b/test/inputs/string_input_test.rb @@ -88,12 +88,12 @@ class StringInputTest < ActionView::TestCase test 'input infers pattern from attributes' do with_input_for @other_validating_user, :country, :string, pattern: true - assert_select 'input[pattern="\w+"]' + assert_select "input:match('pattern', ?)", /\w+/ end test 'input infers pattern from attributes using proc' do with_input_for @other_validating_user, :name, :string, pattern: true - assert_select 'input[pattern="\w+"]' + assert_select "input:match('pattern', ?)", /\w+/ end test 'input does not infer pattern from attributes if root default is false' do @@ -105,7 +105,7 @@ class StringInputTest < ActionView::TestCase test 'input uses given pattern from attributes' do with_input_for @other_validating_user, :country, :string, input_html: { pattern: "\\d+" } - assert_select 'input[pattern="\d+"]' + assert_select "input:match('pattern', ?)", /\\d+/ end test 'input does not use pattern if model has :without validation option' do