rubocop-betterment 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90431e9c1e2edefc54944622ad8885b0ae7bda94bcdea4e1364f766e6d88880a
|
4
|
+
data.tar.gz: d1ee2fcf9fdebb45a726394ddaa36458454cecede00949ed70d43abbe66aa4cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0d493052df02777e92c08759c36e573c452994ed770d0e20059f3f9804f44f914ee1a2985137e0e8b68ec7205ae5125307aeb7f5b8d8fd9c2c2b8976b23b38
|
7
|
+
data.tar.gz: 3fec119ef35007f33a3ce0ab48a2e3bcd2dbfc8abebb1d010e8ca27d728c5cd72cd466af9b2b6fb7b1ee787e88af1191cce90f28d5335fb12ce9b305ba1e36db
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module RuboCop
|
2
|
+
module Cop
|
3
|
+
module Betterment
|
4
|
+
# If a file requires spec_helper or rails_helper, make sure
|
5
|
+
# it is located in a spec/ directory.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# # bad
|
9
|
+
# app/models/whatever_spec.rb
|
10
|
+
# require 'rails_helper'
|
11
|
+
#
|
12
|
+
# # good
|
13
|
+
# spec/models/my_class_spec.rb
|
14
|
+
# require 'rails_helper'
|
15
|
+
class SpecHelperRequiredOutsideSpecDir < Cop
|
16
|
+
MSG = 'Spec helper required outside of a spec/ directory.'.freeze
|
17
|
+
|
18
|
+
def_node_matcher :requires_spec_helper?, <<-PATTERN
|
19
|
+
(send nil? :require
|
20
|
+
(str {"rails_helper" "spec_helper"}))
|
21
|
+
PATTERN
|
22
|
+
|
23
|
+
def on_send(node)
|
24
|
+
add_offense(node, message: MSG) if requires_spec_helper?(node) && !spec_directory?
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def spec_directory?
|
30
|
+
Pathname.new(processed_source.buffer.name)
|
31
|
+
.relative_path_from(Pathname.pwd)
|
32
|
+
.to_s
|
33
|
+
.start_with?("spec#{File::SEPARATOR}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-betterment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Development
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/rubocop/cop/betterment.rb
|
94
94
|
- lib/rubocop/cop/betterment/memoization_with_arguments.rb
|
95
95
|
- lib/rubocop/cop/betterment/site_prism_loaded.rb
|
96
|
+
- lib/rubocop/cop/betterment/spec_helper_required_outside_spec_dir.rb
|
96
97
|
- lib/rubocop/cop/betterment/timeout.rb
|
97
98
|
homepage:
|
98
99
|
licenses:
|