rubocop-rspec 2.29.1 → 2.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/config/default.yml +6 -0
- data/lib/rubocop/cop/rspec/expect_in_let.rb +44 -0
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +1 -1
- data/lib/rubocop/cop/rspec/repeated_subject_call.rb +1 -0
- data/lib/rubocop/cop/rspec_cops.rb +1 -0
- data/lib/rubocop/rspec/node.rb +1 -1
- data/lib/rubocop/rspec/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 037e1076040acc6d3c7efbeecf672ffbbff0b14752f2732681b67ea901c46086
|
4
|
+
data.tar.gz: 052a969aeaebe429e598643005f9cf0a950a1f1a9e0d7e28af59db13094fb22a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abdcaf4cd68964da364c146762c911b54f33b1e244b6216fc79496b45dc9181a3ef87338a98c4559f244d1e49047427b7acbfc2e470b6f14a0a2331a8139d285
|
7
|
+
data.tar.gz: 0fb5243859ef17f6fe01e3eb2bc814079a6b84f53f230f421bfdce8ed8371aab76f29aa24f174f98506cfc7566e3338b0b4d7fc98dbf3954ffce1f93ba620b4d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 2.30.0 (2024-06-03)
|
6
|
+
|
7
|
+
- Add new `RSpec/ExpectInLet` cop. ([@yasu551])
|
8
|
+
|
9
|
+
## 2.29.2 (2024-05-02)
|
10
|
+
|
11
|
+
- Fix beginless and endless range bug for RepeatedIncludeExample cop. ([@hasghari])
|
12
|
+
- Fix a false positive for `RSpec/RepeatedSubjectCall` when subject is used as argument to function call. ([@K-S-A])
|
13
|
+
|
5
14
|
## 2.29.1 (2024-04-05)
|
6
15
|
|
7
16
|
- Fix an error in the default configuration. ([@ydah])
|
@@ -895,6 +904,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
895
904
|
[@gsamokovarov]: https://github.com/gsamokovarov
|
896
905
|
[@harry-graham]: https://github.com/harry-graham
|
897
906
|
[@harrylewis]: https://github.com/harrylewis
|
907
|
+
[@hasghari]: https://github.com/hasghari
|
898
908
|
[@hosamaly]: https://github.com/hosamaly
|
899
909
|
[@ignaciovillaverde]: https://github.com/ignaciovillaverde
|
900
910
|
[@jaredbeck]: https://github.com/jaredbeck
|
@@ -907,6 +917,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
907
917
|
[@jojos003]: https://github.com/jojos003
|
908
918
|
[@jonatas]: https://github.com/jonatas
|
909
919
|
[@jtannas]: https://github.com/jtannas
|
920
|
+
[@k-s-a]: https://github.com/K-S-A
|
910
921
|
[@kellysutton]: https://github.com/kellysutton
|
911
922
|
[@koic]: https://github.com/koic
|
912
923
|
[@kuahyeow]: https://github.com/kuahyeow
|
@@ -969,6 +980,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
969
980
|
[@twalpole]: https://github.com/twalpole
|
970
981
|
[@vzvu3k6k]: https://github.com/vzvu3k6k
|
971
982
|
[@walf443]: https://github.com/walf443
|
983
|
+
[@yasu551]: https://github.com/yasu551
|
972
984
|
[@ybiquitous]: https://github.com/ybiquitous
|
973
985
|
[@ydah]: https://github.com/ydah
|
974
986
|
[@yevhene]: https://github.com/yevhene
|
data/config/default.yml
CHANGED
@@ -447,6 +447,12 @@ RSpec/ExpectInHook:
|
|
447
447
|
VersionAdded: '1.16'
|
448
448
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInHook
|
449
449
|
|
450
|
+
RSpec/ExpectInLet:
|
451
|
+
Description: Do not use `expect` in let.
|
452
|
+
Enabled: pending
|
453
|
+
VersionAdded: '2.30'
|
454
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInLet
|
455
|
+
|
450
456
|
RSpec/ExpectOutput:
|
451
457
|
Description: Checks for opportunities to use `expect { ... }.to output`.
|
452
458
|
Enabled: true
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Do not use `expect` in let.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# let(:foo) do
|
11
|
+
# expect(something).to eq 'foo'
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# it do
|
16
|
+
# expect(something).to eq 'foo'
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
class ExpectInLet < Base
|
20
|
+
MSG = 'Do not use `%<expect>s` in let'
|
21
|
+
|
22
|
+
# @!method expectation(node)
|
23
|
+
def_node_search :expectation, '(send nil? #Expectations.all ...)'
|
24
|
+
|
25
|
+
def on_block(node)
|
26
|
+
return unless let?(node)
|
27
|
+
return if node.body.nil?
|
28
|
+
|
29
|
+
expectation(node.body) do |expect|
|
30
|
+
add_offense(expect.loc.selector, message: message(expect))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
alias on_numblock on_block
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def message(expect)
|
39
|
+
format(MSG, expect: expect.method_name)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -72,7 +72,7 @@ module RuboCop
|
|
72
72
|
MSG = 'Example has too many expectations [%<total>d/%<max>d].'
|
73
73
|
|
74
74
|
ANYTHING = ->(_node) { true }
|
75
|
-
TRUE =
|
75
|
+
TRUE = lambda(&:true_type?)
|
76
76
|
|
77
77
|
# @!method aggregate_failures?(node)
|
78
78
|
def_node_matcher :aggregate_failures?, <<~PATTERN
|
@@ -63,6 +63,7 @@ require_relative 'rspec/excessive_docstring_spacing'
|
|
63
63
|
require_relative 'rspec/expect_actual'
|
64
64
|
require_relative 'rspec/expect_change'
|
65
65
|
require_relative 'rspec/expect_in_hook'
|
66
|
+
require_relative 'rspec/expect_in_let'
|
66
67
|
require_relative 'rspec/expect_output'
|
67
68
|
require_relative 'rspec/file_path'
|
68
69
|
require_relative 'rspec/focus'
|
data/lib/rubocop/rspec/node.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Backus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-06-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/rubocop/cop/rspec/expect_actual.rb
|
137
137
|
- lib/rubocop/cop/rspec/expect_change.rb
|
138
138
|
- lib/rubocop/cop/rspec/expect_in_hook.rb
|
139
|
+
- lib/rubocop/cop/rspec/expect_in_let.rb
|
139
140
|
- lib/rubocop/cop/rspec/expect_output.rb
|
140
141
|
- lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb
|
141
142
|
- lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb
|
@@ -269,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
270
|
- !ruby/object:Gem::Version
|
270
271
|
version: '0'
|
271
272
|
requirements: []
|
272
|
-
rubygems_version: 3.5.
|
273
|
+
rubygems_version: 3.5.9
|
273
274
|
signing_key:
|
274
275
|
specification_version: 4
|
275
276
|
summary: Code style checking for RSpec files
|