From 9025bee88231baed036c51673eee8a11c2a97231 Mon Sep 17 00:00:00 2001 From: ydah Date: Fri, 14 Feb 2025 16:56:46 +0900 Subject: [PATCH] Add safety note for autocorrection in `have_http_status` cop --- docs/modules/ROOT/pages/cops_rspecrails.adoc | 6 ++++++ lib/rubocop/cop/rspec_rails/have_http_status.rb | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/docs/modules/ROOT/pages/cops_rspecrails.adoc b/docs/modules/ROOT/pages/cops_rspecrails.adoc index 07650f96..ced770dc 100644 --- a/docs/modules/ROOT/pages/cops_rspecrails.adoc +++ b/docs/modules/ROOT/pages/cops_rspecrails.adoc @@ -57,6 +57,12 @@ end Checks that tests use `have_http_status` instead of equality matchers. +[#safety-rspecrailshavehttpstatus] +=== Safety + +The autocorrection is marked as unsafe because +`response.status` response is not always an HTTP response. + [#examples-rspecrailshavehttpstatus] === Examples diff --git a/lib/rubocop/cop/rspec_rails/have_http_status.rb b/lib/rubocop/cop/rspec_rails/have_http_status.rb index 71bd168d..e2894173 100644 --- a/lib/rubocop/cop/rspec_rails/have_http_status.rb +++ b/lib/rubocop/cop/rspec_rails/have_http_status.rb @@ -5,6 +5,10 @@ module Cop module RSpecRails # Checks that tests use `have_http_status` instead of equality matchers. # + # @safety + # The autocorrection is marked as unsafe because + # `response.status` response is not always an HTTP response. + # # @example ResponseMethods: ['response', 'last_response'] (default) # # bad # expect(response.status).to be(200)