sevencop 0.36.0 → 0.38.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +2 -2
- data/README.md +1 -0
- data/config/default.yml +17 -12
- data/lib/rubocop/cop/sevencop/rspec_rails_have_http_status.rb +66 -0
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dc6aed08986989bb0d31d172c6c08426a9581f2aac31c85a9730ba4ba2f5ea8
|
4
|
+
data.tar.gz: 62a2bdf5a54bf07578bcb40c6accb56075f85ff6ff56a45435efde1836413e42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 236dab0fff5322449648b6a99223b5800d2d9444bcaf02f0e69b1cee63c2fb0fb91b3ad792407c9ef8a79cac502e3099f460955f01e93c7da412291214e44cb6
|
7
|
+
data.tar.gz: 4066d32b53e2618e2d3e138742ba0b23652c266561b36ba34670519401f4d823654a0f25f4d06b3dc3f38345cb960d69bed51e37d2025b31624d0f34d89a2675
|
data/.rubocop.yml
CHANGED
@@ -19,6 +19,7 @@ Layout/LineLength:
|
|
19
19
|
Lint/UselessAccessModifier:
|
20
20
|
MethodCreatingMethods:
|
21
21
|
- def_node_matcher
|
22
|
+
- def_node_search
|
22
23
|
|
23
24
|
Metrics:
|
24
25
|
Enabled: false
|
@@ -39,6 +40,7 @@ RSpec/FilePath:
|
|
39
40
|
RSpecEmptyLineAfterLet: rspec_empty_line_after_let
|
40
41
|
RSpecExamplesInSameGroup: rspec_examples_in_same_group
|
41
42
|
RSpecMemoizedHelperBlockDelimiter: rspec_memoized_helper_block_delimiter
|
43
|
+
RSpecRailsHaveHttpStatus: rspec_rails_have_http_status
|
42
44
|
|
43
45
|
RSpec/MultipleExpectations:
|
44
46
|
Enabled: false
|
@@ -49,6 +51,7 @@ RSpec/SpecFilePathFormat:
|
|
49
51
|
RSpecEmptyLineAfterLet: rspec_empty_line_after_let
|
50
52
|
RSpecExamplesInSameGroup: rspec_examples_in_same_group
|
51
53
|
RSpecMemoizedHelperBlockDelimiter: rspec_memoized_helper_block_delimiter
|
54
|
+
RSpecRailsHaveHttpStatus: rspec_rails_have_http_status
|
52
55
|
|
53
56
|
Sevencop/AutoloadOrdered:
|
54
57
|
Enabled: true
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sevencop (0.
|
4
|
+
sevencop (0.38.0)
|
5
5
|
activesupport
|
6
6
|
rubocop
|
7
7
|
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
concurrent-ruby (~> 1.0)
|
31
31
|
json (2.7.1)
|
32
32
|
language_server-protocol (3.17.0.3)
|
33
|
-
minitest (5.
|
33
|
+
minitest (5.22.2)
|
34
34
|
mutex_m (0.2.0)
|
35
35
|
parallel (1.24.0)
|
36
36
|
parser (3.3.0.5)
|
data/README.md
CHANGED
@@ -48,6 +48,7 @@ Note that all cops are `Enabled: false` by default.
|
|
48
48
|
- [Sevencop/RSpecEmptyLineAfterLet](lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb)
|
49
49
|
- [Sevencop/RSpecExamplesInSameGroup](lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb)
|
50
50
|
- [Sevencop/RSpecMemoizedHelperBlockDelimiter](lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb)
|
51
|
+
- [Sevencop/RSpecRailsHaveHttpStatus](lib/rubocop/cop/sevencop/rspec_rails_have_http_status.rb)
|
51
52
|
|
52
53
|
## Notes
|
53
54
|
|
data/config/default.yml
CHANGED
@@ -24,12 +24,9 @@ Sevencop/FactoryBotAssociationStyle:
|
|
24
24
|
NonImplicitAssociationMethodNames:
|
25
25
|
- skip_create
|
26
26
|
Include:
|
27
|
-
- factories.rb
|
28
|
-
- factories/*.rb
|
29
|
-
-
|
30
|
-
- spec/factories/*.rb
|
31
|
-
- test/factories.rb
|
32
|
-
- test/factories/*.rb
|
27
|
+
- "**/factories.rb"
|
28
|
+
- "**/spec/factories/*.rb"
|
29
|
+
- "**/test/factories/*.rb"
|
33
30
|
|
34
31
|
Sevencop/HashElementOrdered:
|
35
32
|
Description: |
|
@@ -103,7 +100,7 @@ Sevencop/RailsSpecificActionName:
|
|
103
100
|
- show
|
104
101
|
- update
|
105
102
|
Include:
|
106
|
-
- app/controllers/**/*.rb
|
103
|
+
- "**/app/controllers/**/*.rb"
|
107
104
|
|
108
105
|
Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity:
|
109
106
|
Description: |
|
@@ -122,14 +119,14 @@ Sevencop/RSpecDescribeHttpEndpoint:
|
|
122
119
|
Pass HTTP endpoint identifier (e.g. `GET /users`) to top-level `describe` on request-specs.
|
123
120
|
Enabled: false
|
124
121
|
Include:
|
125
|
-
- spec/requests/**/*.rb
|
122
|
+
- "**/spec/requests/**/*.rb"
|
126
123
|
|
127
124
|
Sevencop/RSpecEmptyLineAfterLet:
|
128
125
|
Description: |
|
129
126
|
Insert empty line after `let`.
|
130
127
|
Enabled: false
|
131
128
|
Include:
|
132
|
-
- spec
|
129
|
+
- "**/spec/**/*.rb"
|
133
130
|
|
134
131
|
Sevencop/RSpecExamplesInSameGroup:
|
135
132
|
Description: |
|
@@ -137,12 +134,20 @@ Sevencop/RSpecExamplesInSameGroup:
|
|
137
134
|
Enabled: false
|
138
135
|
IncludeSharedExamples: false
|
139
136
|
Include:
|
140
|
-
- spec/controllers
|
141
|
-
- spec/requests
|
137
|
+
- "**/spec/controllers/**/*.rb"
|
138
|
+
- "**/spec/requests/**/*.rb"
|
142
139
|
|
143
140
|
Sevencop/RSpecMemoizedHelperBlockDelimiter:
|
144
141
|
Description: |
|
145
142
|
Use do-end block delimiter on RSpec memoized helper.
|
146
143
|
Enabled: false
|
147
144
|
Include:
|
148
|
-
- spec
|
145
|
+
- "**/spec/**/*.rb"
|
146
|
+
|
147
|
+
Sevencop/RSpecRailsHaveHttpStatus:
|
148
|
+
Description: |
|
149
|
+
Always check status code with `have_http_status`.
|
150
|
+
Enabled: false
|
151
|
+
Include:
|
152
|
+
- "**/spec/controllers/**/*.rb"
|
153
|
+
- "**/spec/requests/**/*.rb"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sevencop
|
6
|
+
# Always check status code with `have_http_status`.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# it 'creates a new post' do
|
11
|
+
# expect { subject }.to change(Post, :count).by(1)
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# it 'creates a new post' do
|
16
|
+
# expect { subject }.to change(Post, :count).by(1)
|
17
|
+
# expect(response).to have_http_status(200)
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# # good
|
21
|
+
# it 'creates a new post' do
|
22
|
+
# expect { subject }.to change(Post, :count).by(1)
|
23
|
+
# expect(response).to redirect_to(posts_path)
|
24
|
+
# end
|
25
|
+
class RSpecRailsHaveHttpStatus < Base
|
26
|
+
MSG = 'Always check status code with `have_http_status`.'
|
27
|
+
|
28
|
+
EXAMPLE_METHOD_NAMES = %i[
|
29
|
+
example
|
30
|
+
it
|
31
|
+
specify
|
32
|
+
].to_set.freeze
|
33
|
+
|
34
|
+
STATUS_CHECK_METHOD_NAMES = %i[
|
35
|
+
have_http_status
|
36
|
+
redirect_to
|
37
|
+
].to_set.freeze
|
38
|
+
|
39
|
+
# @param [RuboCop::AST::BlockNode] node
|
40
|
+
# @return [void]
|
41
|
+
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
42
|
+
return unless example_method?(node)
|
43
|
+
return if including_status_check_method?(node)
|
44
|
+
|
45
|
+
add_offense(node)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# @!method example_method?(node)
|
51
|
+
# @param [RuboCop::AST::BlockNode] node
|
52
|
+
# @return [Boolean]
|
53
|
+
def_node_matcher :example_method?, <<~PATTERN
|
54
|
+
(block (send nil? EXAMPLE_METHOD_NAMES ...) ...)
|
55
|
+
PATTERN
|
56
|
+
|
57
|
+
# @!method including_status_check_method?(node)
|
58
|
+
# @param [RuboCop::AST::BlockNode] node
|
59
|
+
# @return [Boolean]
|
60
|
+
def_node_search :including_status_check_method?, <<~PATTERN
|
61
|
+
(send nil? STATUS_CHECK_METHOD_NAMES ...)
|
62
|
+
PATTERN
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/sevencop/version.rb
CHANGED
data/lib/sevencop.rb
CHANGED
@@ -24,3 +24,4 @@ require_relative 'rubocop/cop/sevencop/rspec_describe_http_endpoint'
|
|
24
24
|
require_relative 'rubocop/cop/sevencop/rspec_empty_line_after_let'
|
25
25
|
require_relative 'rubocop/cop/sevencop/rspec_examples_in_same_group'
|
26
26
|
require_relative 'rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter'
|
27
|
+
require_relative 'rubocop/cop/sevencop/rspec_rails_have_http_status'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sevencop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.38.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb
|
77
77
|
- lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb
|
78
78
|
- lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb
|
79
|
+
- lib/rubocop/cop/sevencop/rspec_rails_have_http_status.rb
|
79
80
|
- lib/sevencop.rb
|
80
81
|
- lib/sevencop/config_loader.rb
|
81
82
|
- lib/sevencop/cop_concerns.rb
|