empty_example_cop 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/config/default.yml +1 -0
- data/lib/empty_example_cop/version.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_example_cops.rb +14 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '096f55917d0f21e125d90a8126c533fbff48df8d7695bcff14879ae6d894dbc4'
|
4
|
+
data.tar.gz: bf13a1aa5321e5565451c00d90948da370661834b3ec75a1b4f2a1578e9163e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ee09ad3a6d184e23bd4dfeb3c1743170f9907bd9afd7b2345fc73cec11f15b136ad52ebea2debfee307f9e4ba6ad39d3509d4e2ee3dbaf5e456f2512cad74a3
|
7
|
+
data.tar.gz: d73461f323bf058bfeedf0c295d5ae0fe11953ee9fb58b4e972169cc479407e45a6a4439a264cc5034ec885d3699226c88d8ac1ec35ff344db4dc5ebc6084205
|
data/CHANGELOG.md
CHANGED
data/config/default.yml
CHANGED
@@ -4,6 +4,10 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module RSpec
|
6
6
|
class EmptyExample < Base
|
7
|
+
extend AutoCorrector
|
8
|
+
|
9
|
+
include RangeHelp
|
10
|
+
|
7
11
|
# Checks if an example does not include any expectations.
|
8
12
|
#
|
9
13
|
# @example usage
|
@@ -29,9 +33,9 @@ module RuboCop
|
|
29
33
|
# end
|
30
34
|
MSG = 'Empty example detected.'
|
31
35
|
|
32
|
-
def_node_matcher :it_description
|
36
|
+
def_node_matcher :it_description, <<-PATTERN
|
33
37
|
(block
|
34
|
-
(send nil? :it
|
38
|
+
(send nil? :it $...) ...)
|
35
39
|
PATTERN
|
36
40
|
|
37
41
|
def_node_matcher :expect?, <<-PATTERN
|
@@ -47,10 +51,16 @@ module RuboCop
|
|
47
51
|
PATTERN
|
48
52
|
|
49
53
|
def on_block(node)
|
50
|
-
|
54
|
+
description = it_description(node)
|
55
|
+
return if description.nil?
|
51
56
|
|
52
57
|
unless example_present?(node)
|
53
|
-
add_offense(node, message: MSG)
|
58
|
+
add_offense(node, message: MSG) do |corrector|
|
59
|
+
corrector.replace(
|
60
|
+
range_by_whole_lines(node.location.expression),
|
61
|
+
"it #{description.last&.source}"
|
62
|
+
)
|
63
|
+
end
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: empty_example_cop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- makicamel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|