From e1b5f3fc6f1bb6e77a7cad725a963d008c7ce983 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 4 Sep 2024 13:29:05 -0400 Subject: [PATCH] Use `response.parsed_body` for html response checks (#31750) --- spec/controllers/admin/accounts_controller_spec.rb | 2 +- .../admin/export_domain_blocks_controller_spec.rb | 2 +- .../controllers/admin/instances_controller_spec.rb | 2 +- .../auth/registrations_controller_spec.rb | 2 +- spec/requests/account_show_page_spec.rb | 14 ++++++++------ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 89a7239f53f..ca399fbd9bb 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -48,7 +48,7 @@ RSpec.describe Admin::AccountsController do end def accounts_table_rows - Nokogiri::Slop(response.body).css('table.accounts-table tr') + response.parsed_body.css('table.accounts-table tr') end end diff --git a/spec/controllers/admin/export_domain_blocks_controller_spec.rb b/spec/controllers/admin/export_domain_blocks_controller_spec.rb index 39195716c5c..564f5a88c51 100644 --- a/spec/controllers/admin/export_domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/export_domain_blocks_controller_spec.rb @@ -64,7 +64,7 @@ RSpec.describe Admin::ExportDomainBlocksController do end def batch_table_rows - Nokogiri::Slop(response.body).css('body div.batch-table__row') + response.parsed_body.css('body div.batch-table__row') end end diff --git a/spec/controllers/admin/instances_controller_spec.rb b/spec/controllers/admin/instances_controller_spec.rb index a64bbb2c9f7..1e65373e1f5 100644 --- a/spec/controllers/admin/instances_controller_spec.rb +++ b/spec/controllers/admin/instances_controller_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Admin::InstancesController do end def instance_directory_links - Nokogiri::Slop(response.body).css('div.directory__tag a') + response.parsed_body.css('div.directory__tag a') end end diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 75ab2876523..6118edf4e34 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -342,7 +342,7 @@ RSpec.describe Auth::RegistrationsController do end def username_error_text - Nokogiri::Slop(response.body).css('.user_account_username .error').text + response.parsed_body.css('.user_account_username .error').text end end diff --git a/spec/requests/account_show_page_spec.rb b/spec/requests/account_show_page_spec.rb index d0857c8980e..7f3ea2595f8 100644 --- a/spec/requests/account_show_page_spec.rb +++ b/spec/requests/account_show_page_spec.rb @@ -18,14 +18,16 @@ RSpec.describe 'The account show page' do end def head_link_icons - head_section.css('link[rel=icon]') + response + .parsed_body + .search('html head link[rel=icon]') end def head_meta_content(property) - head_section.meta("[@property='#{property}']")[:content] - end - - def head_section - Nokogiri::Slop(response.body).html.head + response + .parsed_body + .search("html head meta[property='#{property}']") + .attr('content') + .text end end