Skip to content

Commit 5547ab7

Browse files
committed
Change RSpecRails/HaveHttpStatus from Autocorrect: false to Safe: false
Fixes: #5 This is because `response.status` is not always the HTTP response as commented below. I don't think this is an autocorrect is not safe. What do you think? rubocop/rubocop-rspec#1307 (comment)
1 parent 801dfe4 commit 5547ab7

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Master (Unreleased)
44

55
- Handle unknown HTTP status codes for `RSpecRails/HttpStatus` cop. ([@viralpraxis])
6+
- Change `RSpecRails/HaveHttpStatus` from `Autocorrect: false` to `Safe: false`. ([@ydah])
67

78
## 2.30.0 (2024-06-12)
89

config/default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ RSpecRails/HaveHttpStatus:
1818
ResponseMethods:
1919
- response
2020
- last_response
21-
SafeAutoCorrect: false
21+
Safe: false
2222
VersionAdded: '2.12'
23-
VersionChanged: '2.27'
23+
VersionChanged: "<<next>>"
2424
Reference: https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/HaveHttpStatus
2525

2626
RSpecRails/HttpStatus:

docs/modules/ROOT/pages/cops_rspecrails.adoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,20 @@ end
4949
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
5050
5151
| Pending
52-
| Yes
52+
| No
5353
| Always (Unsafe)
5454
| 2.12
55-
| 2.27
55+
| <<next>>
5656
|===
5757
5858
Checks that tests use `have_http_status` instead of equality matchers.
5959
60+
[#safety-rspecrailshavehttpstatus]
61+
=== Safety
62+
63+
This cop is marked as unsafe because
64+
`response.status` response is not always an HTTP response.
65+
6066
[#examples-rspecrailshavehttpstatus]
6167
=== Examples
6268

lib/rubocop/cop/rspec_rails/have_http_status.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module Cop
55
module RSpecRails
66
# Checks that tests use `have_http_status` instead of equality matchers.
77
#
8+
# @safety
9+
# This cop is marked as unsafe because
10+
# `response.status` response is not always an HTTP response.
11+
#
812
# @example ResponseMethods: ['response', 'last_response'] (default)
913
# # bad
1014
# expect(response.status).to be(200)

0 commit comments

Comments
 (0)