sevencop 0.16.0 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/config/default.yml +9 -0
- data/lib/rubocop/cop/sevencop/method_definition_arguments_multiline.rb +1 -0
- data/lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb +75 -0
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +1 -0
- data/sevencop.gemspec +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 822706ee0729871b2da9cb6fdc7de31d891a53bfb5aa633c55cdb862b2689e36
|
4
|
+
data.tar.gz: 326bb123620fed30e14cab5ac033228b1cddd9a3ace6b06efccb4cca24534658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc0f7ac09c0262566fb15f2d397a546b54c80f56e933350a00e2e1c96b3cc5d0d04249350ac2f837ea83057d0308b241c54b236670eb384c43968bde8d9e28d
|
7
|
+
data.tar.gz: 064e3454888d29fb35f585b30f58609d01db1ed5da17ecf50c8ebb2ec309b111d769ee2a2cacae7d3988c48a49cc46d303df87a66a93def0b44dd1227141d037
|
data/.rubocop.yml
CHANGED
@@ -10,6 +10,9 @@ AllCops:
|
|
10
10
|
SuggestExtensions: false
|
11
11
|
TargetRubyVersion: 2.6
|
12
12
|
|
13
|
+
Gemspec/RequireMFA:
|
14
|
+
Enabled: false
|
15
|
+
|
13
16
|
Metrics:
|
14
17
|
Enabled: false
|
15
18
|
|
@@ -23,6 +26,10 @@ RSpec:
|
|
23
26
|
RSpec/ExampleLength:
|
24
27
|
Enabled: false
|
25
28
|
|
29
|
+
RSpec/FilePath:
|
30
|
+
CustomTransform:
|
31
|
+
RSpecExamplesInSameGroup: rspec_examples_in_same_group
|
32
|
+
|
26
33
|
RSpec/MultipleExpectations:
|
27
34
|
Enabled: false
|
28
35
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -39,5 +39,6 @@ Choose the cops you want to use and enable them on your .rubocop.yml.
|
|
39
39
|
- [Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity](lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb)
|
40
40
|
- [Sevencop/RailsWhereNot](lib/rubocop/cop/sevencop/rails_where_not.rb)
|
41
41
|
- [Sevencop/RequireOrdered](lib/rubocop/cop/sevencop/require_ordered.rb)
|
42
|
+
- [Sevencop/RSpecExamplesInSameGroup](lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb)
|
42
43
|
|
43
44
|
Note that all cops are `Enabled: false` by default.
|
data/config/default.yml
CHANGED
@@ -67,3 +67,12 @@ Sevencop/RequireOrdered:
|
|
67
67
|
Sort `require` and `require_relative` in alphabetical order.
|
68
68
|
Enabled: false
|
69
69
|
VersionAdded: '0.16'
|
70
|
+
|
71
|
+
Sevencop/RSpecExamplesInSameGroup:
|
72
|
+
Description: |
|
73
|
+
Combine examples in the same groups in the time-consuming kinds of specs.
|
74
|
+
Enabled: false
|
75
|
+
VersionAdded: '0.17'
|
76
|
+
Include:
|
77
|
+
- spec/controllers/**/*
|
78
|
+
- spec/requests/**/*
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sevencop
|
6
|
+
# Combine examples in same group in the time-consuming kinds of specs.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# # bad
|
11
|
+
# context 'when user is logged in' do
|
12
|
+
# it 'returns 200' do
|
13
|
+
# subject
|
14
|
+
# expect(response).to have_http_status(200)
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# it 'creates Foo' do
|
18
|
+
# expect { subject }.to change(Foo, :count).by(1)
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# # good
|
23
|
+
# context 'when user is logged in' do
|
24
|
+
# it 'creates Foo and returns 200' do
|
25
|
+
# expect { subject }.to change(Foo, :count).by(1)
|
26
|
+
# expect(response).to have_http_status(200)
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
class RSpecExamplesInSameGroup < Base
|
31
|
+
EXAMPLE_METHOD_NAMES_REGULAR = ::Set[
|
32
|
+
:it,
|
33
|
+
:its,
|
34
|
+
:specify,
|
35
|
+
:example,
|
36
|
+
:scenario,
|
37
|
+
].freeze
|
38
|
+
|
39
|
+
MSG = 'Combine examples in the same group in the time-consuming kinds of specs.'
|
40
|
+
|
41
|
+
# @param node [RuboCop::AST::BlockNode]
|
42
|
+
# @return [void]
|
43
|
+
def on_block(node)
|
44
|
+
return unless example?(node)
|
45
|
+
|
46
|
+
previous_sibling_example = previous_sibling_example_of(node)
|
47
|
+
return unless previous_sibling_example
|
48
|
+
|
49
|
+
add_offense(node)
|
50
|
+
end
|
51
|
+
alias on_numblock on_block
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
# @!method example?(node)
|
56
|
+
# @param node [RuboCop::AST::Node]
|
57
|
+
# @return [Boolean]
|
58
|
+
def_node_matcher :example?, <<~PATTERN
|
59
|
+
(block
|
60
|
+
(send nil? EXAMPLE_METHOD_NAMES_REGULAR ...)
|
61
|
+
...
|
62
|
+
)
|
63
|
+
PATTERN
|
64
|
+
|
65
|
+
# @param node [RuboCop::AST::BlockNode]
|
66
|
+
# @return [RuboCop::AST::BlockNode, nil]
|
67
|
+
def previous_sibling_example_of(node)
|
68
|
+
node.left_siblings.find do |sibling|
|
69
|
+
sibling.is_a?(::RuboCop::AST::Node) && example?(sibling)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/sevencop/version.rb
CHANGED
data/lib/sevencop.rb
CHANGED
@@ -15,3 +15,4 @@ require_relative 'rubocop/cop/sevencop/rails_order_field'
|
|
15
15
|
require_relative 'rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity'
|
16
16
|
require_relative 'rubocop/cop/sevencop/rails_where_not'
|
17
17
|
require_relative 'rubocop/cop/sevencop/require_ordered'
|
18
|
+
require_relative 'rubocop/cop/sevencop/rspec_examples_in_same_group'
|
data/sevencop.gemspec
CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
17
17
|
spec.metadata['source_code_uri'] = spec.homepage
|
18
18
|
spec.metadata['changelog_uri'] = "#{spec.homepage}/releases"
|
19
|
-
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
19
|
|
21
20
|
# Specify which files should be added to the gem when it is released.
|
22
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
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.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb
|
53
53
|
- lib/rubocop/cop/sevencop/rails_where_not.rb
|
54
54
|
- lib/rubocop/cop/sevencop/require_ordered.rb
|
55
|
+
- lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb
|
55
56
|
- lib/sevencop.rb
|
56
57
|
- lib/sevencop/config_loader.rb
|
57
58
|
- lib/sevencop/cop_concerns.rb
|
@@ -66,7 +67,6 @@ metadata:
|
|
66
67
|
homepage_uri: https://github.com/r7kamura/sevencop
|
67
68
|
source_code_uri: https://github.com/r7kamura/sevencop
|
68
69
|
changelog_uri: https://github.com/r7kamura/sevencop/releases
|
69
|
-
rubygems_mfa_required: 'true'
|
70
70
|
post_install_message:
|
71
71
|
rdoc_options: []
|
72
72
|
require_paths:
|