danger-spec_postfix 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/lib/spec_postfix/gem_version.rb +1 -1
- data/lib/spec_postfix/plugin.rb +15 -15
- data/spec/spec_postfix_spec.rb +5 -5
- 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: 1e94dcdaa6eb52bb583fdef4533f843d29ccc832f09ab8730d9c4f3c6ceeb780
|
4
|
+
data.tar.gz: e532443dfd5b7badf64345f986aa6e8e05f7ab3925ba0bb0298ba929fd724223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1295e07b4d9b57469dd87d26c7adb599bd4488108a7a46f746f98d02ca42ac37857de295e8993c4f99b8a2f8d57ee6ca0c4872b8f332f57ead04ebce4093bb9e
|
7
|
+
data.tar.gz: b2d937ab25d4680814d103ee61402e969929f3644fd55172fa08b05f6472e4741dff4360ecaa08a8c3466b288b282d9a2ecd9cabbe3853fcacfa6e8d92601136
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -15,20 +15,20 @@ Danger plugin to validate files (or directories) naming.
|
|
15
15
|
```
|
16
16
|
options = {
|
17
17
|
message: 'Tests should have `_spec` postfix',
|
18
|
-
|
18
|
+
include_path: %r{spec/},
|
19
19
|
match: %r{_spec.rb$}
|
20
20
|
}
|
21
21
|
spec_postfix.lint(options)
|
22
22
|
```
|
23
23
|
|
24
|
-
You can also pass `
|
24
|
+
You can also pass `exclude_path` param in order to skip irrelevant files or directories:
|
25
25
|
|
26
26
|
```
|
27
27
|
options = {
|
28
28
|
message: 'Tests should have `_spec` postfix',
|
29
|
-
|
29
|
+
include_path: %r{spec/},
|
30
30
|
match: %r{_spec.rb$}
|
31
|
-
|
31
|
+
exclude_path: Regexp.union(%r{rails_helper.rb}, %r{rails_helper.rb}, %{spec/factories/}, %r{spec/support/})
|
32
32
|
}
|
33
33
|
spec_postfix.lint(options)
|
34
34
|
```
|
data/lib/spec_postfix/plugin.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Danger
|
4
|
-
# Lints files (or directories) naming.
|
5
|
-
# Generates a `string` with warning.
|
6
|
-
#
|
7
|
-
# @param [Array<String>] files
|
8
|
-
# A globbed string which should return the files that you want to lint, defaults to nil.
|
9
|
-
# if nil, modified and added files from the diff will be used.
|
10
|
-
# @param scope [Regexp] Scope of check
|
11
|
-
# @param match [Regexp] Pattern to match
|
12
|
-
# @param message [String] Warn message
|
13
|
-
# @param exception [Regexp] Not required. In case you want to get some directories or files out of scope.
|
14
|
-
# @return [void]
|
15
|
-
#
|
16
4
|
class DangerSpecPostfix < Plugin
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
# Lints files (or directories) naming.
|
6
|
+
# Generates a `string` with warning.
|
7
|
+
#
|
8
|
+
# @param files [Array<String>]
|
9
|
+
# A globbed string which should return the files that you want to lint, defaults to nil.
|
10
|
+
# if nil, modified and added files from the diff will be used.
|
11
|
+
# @param include_path [Regexp] Scope of check
|
12
|
+
# @param match [Regexp] Pattern to match
|
13
|
+
# @param message [String] Warn message
|
14
|
+
# @param exclude_path [Regexp] Not required. In case you want to have some directories or files exceptions.
|
15
|
+
# @return [void]
|
16
|
+
#
|
17
|
+
def lint(include_path:, match:, message:, exclude_path: nil)
|
18
|
+
wrong_files = changed_files.select { |f| f.match?(include_path) }.reject { |f| f.match?(match) }
|
19
|
+
wrong_files = wrong_files.reject { |f| f.match?(exclude_path) } if exclude_path
|
20
20
|
wrong_files.each { |f| warn("#{message}: #{f}") }
|
21
21
|
end
|
22
22
|
|
data/spec/spec_postfix_spec.rb
CHANGED
@@ -15,12 +15,12 @@ module Danger
|
|
15
15
|
end
|
16
16
|
|
17
17
|
let(:message) { 'Tests should have `_spec` postfix' }
|
18
|
-
let(:
|
18
|
+
let(:include_path) { %r{spec/} }
|
19
19
|
let(:match) { %r{_spec.rb$} }
|
20
20
|
let(:options) do
|
21
21
|
{
|
22
22
|
message: message,
|
23
|
-
|
23
|
+
include_path: include_path,
|
24
24
|
match: match
|
25
25
|
}
|
26
26
|
end
|
@@ -47,13 +47,13 @@ module Danger
|
|
47
47
|
let(:options) do
|
48
48
|
{
|
49
49
|
message: message,
|
50
|
-
|
50
|
+
include_path: include_path,
|
51
51
|
match: match,
|
52
|
-
|
52
|
+
exclude_path: exclude_path
|
53
53
|
}
|
54
54
|
end
|
55
55
|
let(:file_path) { 'spec/spec_helper.rb' }
|
56
|
-
let(:
|
56
|
+
let(:exclude_path) { Regexp.union(%r{spec/factories}, %r{spec_helper.rb}) }
|
57
57
|
|
58
58
|
it { is_expected.to be_empty }
|
59
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-spec_postfix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Udalov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
204
|
- !ruby/object:Gem::Version
|
205
205
|
version: '0'
|
206
206
|
requirements: []
|
207
|
-
rubygems_version: 3.
|
207
|
+
rubygems_version: 3.3.26
|
208
208
|
signing_key:
|
209
209
|
specification_version: 4
|
210
210
|
summary: Danger plugin to validate files (or directories) naming.
|