File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
lib/rubocop/cop/rspec/rails
spec/rubocop/cop/rspec/rails Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,9 @@ module Rails
16
16
class HaveHttpStatus < Base
17
17
extend AutoCorrector
18
18
19
- MSG = 'Prefer `expect(response.status).%<to>s %<match>s` ' \
20
- 'over `expect(response).%<to>s have_http_status(%<status>i)`.'
19
+ MSG =
20
+ 'Prefer `expect(response).%<to>s have_http_status(%<status>i)` ' \
21
+ 'over `expect(response.status).%<to>s %<match>s`.'
21
22
22
23
# @!method match_status(node)
23
24
def_node_matcher :match_status , <<-PATTERN
Original file line number Diff line number Diff line change 4
4
it 'registers an offense for `expect(response.status).to be 200`' do
5
5
expect_offense ( <<~RUBY )
6
6
it { expect(response.status).to be 200 }
7
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `expect(response.status ).to be 200` over `expect(response).to have_http_status( 200) `.
7
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `expect(response).to have_http_status( 200) ` over `expect(response.status ).to be 200`.
8
8
RUBY
9
9
10
10
expect_correction ( <<~RUBY )
15
15
it 'registers an offense for `expect(response.status).not_to eq 404`' do
16
16
expect_offense ( <<~RUBY )
17
17
it { expect(response.status).not_to eq(404) }
18
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `expect(response.status ).not_to eq (404)` over `expect(response).not_to have_http_status (404)`.
18
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `expect(response).not_to have_http_status (404)` over `expect(response.status ).not_to eq (404)`.
19
19
RUBY
20
20
21
21
expect_correction ( <<~RUBY )
You can’t perform that action at this time.
0 commit comments