danger-spec_postfix 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15c7d8c52818ceb68184f56d5cd1ec453d54b074d31b002861ec124fc2bf09d0
4
- data.tar.gz: be8b28379ac2001acc446ca49481c70ea3e812aba5dc0c1bb3213cfe7f863ec4
3
+ metadata.gz: d7013f18e0074dbc9108182afd4409ee9457760bcf0114a3a107c4fc448ac2a3
4
+ data.tar.gz: 4530c9d8fdc42da2af6dc6d68e01f213fbb71b3c4fe536b182859e1f4addcb1c
5
5
  SHA512:
6
- metadata.gz: e8129452944e17e50dd6821a47ec71adf77b9796cd896c5a9eb86540838dcb37586c0dd80961a5bf7a7cb95632a31799b0d393c6d996a9b89e1813d6114372a8
7
- data.tar.gz: 2ba88f4ccc36da3eff3902f2e0c85bb72899b331ca5dbf4d9d88b74518a41679cbf2f4071bc6395f348a558c957723e46e0ef412bdcfcc10cc697a9641a82ae1
6
+ metadata.gz: 4989e8df6156ddec96e0ec46563fe823a162449de773e6f6a69e3bcde7e2fd2475c26a20ce100cd3fcad8d54025fb7c9bfc78357a13add250c04897fd9f642fe
7
+ data.tar.gz: 825eaf57bc666f914692af8879725ab03becca562a71aad50751b8f0a856e7e7b3eff3b60e1bcd7e8966139542cb2bfa6ef26cead6974bbac9b02e4c05336bd1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-spec_postfix (0.0.1)
4
+ danger-spec_postfix (0.0.3)
5
5
  danger-plugin-api (~> 1.0)
6
6
 
7
7
  GEM
@@ -96,7 +96,7 @@ GEM
96
96
  rb-inotify (>= 0.9.7)
97
97
  lumberjack (1.2.8)
98
98
  method_source (1.0.0)
99
- minitest (5.16.3)
99
+ minitest (5.17.0)
100
100
  multipart-post (2.2.3)
101
101
  nap (1.1.0)
102
102
  nenv (0.3.0)
@@ -132,7 +132,7 @@ GEM
132
132
  rspec-expectations (3.12.2)
133
133
  diff-lcs (>= 1.2.0, < 2.0)
134
134
  rspec-support (~> 3.12.0)
135
- rspec-mocks (3.12.2)
135
+ rspec-mocks (3.12.3)
136
136
  diff-lcs (>= 1.2.0, < 2.0)
137
137
  rspec-support (~> 3.12.0)
138
138
  rspec-support (3.12.0)
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/rambler-digital-solutions/danger-spec_postfix'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpecPostfix
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.3'
5
5
  end
@@ -1,38 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/configurable'
4
-
5
3
  module Danger
6
- # Check that all test files in spec/ folder have `_spec` postfix.
7
- # Results are passed out as a string with warning.
8
- #
9
- # @example Running linter
4
+ # Lints the test files. Will fail if any has no '_spec' postfix.
5
+ # Generates a `string` with warning.
10
6
  #
11
- # # Runs a linter
12
- # spec_postfix.lint
7
+ # @param [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
+ # @return [void]
13
11
  #
14
12
  class DangerSpecPostfix < Plugin
15
- # Lints the test files. Will fail if any has no '_spec' postfix.
16
- # Generates a `string` with warning.
17
- #
18
- # @param [String] files
19
- # A globbed string which should return the files that you want to lint, defaults to nil.
20
- # if nil, modified and added files from the diff will be used.
21
- # @return [void]
22
- #
23
- def self.configuration
24
- @configuration ||= Configuration.new
25
- end
26
-
27
- def self.configure
28
- yield configuration
29
- end
30
-
31
- def lint
13
+ def lint(exceptions: [])
32
14
  changed_files.select { |f| f.match?(%r{^spec/.*rb$}) }
33
- .reject { |f| f.end_with?('_spec.rb') }
34
- .reject { |f| DangerSpecPostfix.configuration.exceptions.any? { |e| f.start_with?(e) } }
35
- .each { |f| warn(warning_generator(f)) }
15
+ .reject { |f| f.end_with?('_spec.rb') }
16
+ .reject { |f| exceptions.any? { |e| f.start_with?(e) } }
17
+ .each { |f| warn(warning_generator(f)) }
36
18
  end
37
19
 
38
20
  private
@@ -45,10 +27,4 @@ module Danger
45
27
  "Tests should have `_spec` postfix: #{file}"
46
28
  end
47
29
  end
48
-
49
- class DangerSpecPostfix::Configuration
50
- include ::ActiveSupport::Configurable
51
-
52
- config_accessor(:exceptions) { ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb'] }
53
- end
54
30
  end
data/spec/spec_helper.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'pathname'
4
4
  ROOT = Pathname.new(File.expand_path('..', __dir__))
5
- $:.unshift("#{ROOT}lib")
6
- $:.unshift("#{ROOT}spec")
5
+ $LOAD_PATH.unshift("#{ROOT}lib")
6
+ $LOAD_PATH.unshift("#{ROOT}spec")
7
7
 
8
8
  require 'bundler/setup'
9
9
  require 'pry'
@@ -36,10 +36,9 @@ module Danger
36
36
  end
37
37
 
38
38
  context 'when is irrelevant (exceptions)' do
39
- before do
40
- described_class.configure do |config|
41
- config.exceptions = 'not_tests/'
42
- end
39
+ subject do
40
+ @spec_postfix.lint(exceptions: ['not_tests/'])
41
+ @spec_postfix.status_report[:warnings]
43
42
  end
44
43
 
45
44
  let(:file_path) { 'not_tests/factory.rb' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-spec_postfix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Udalov
@@ -174,25 +174,16 @@ files:
174
174
  - Gemfile
175
175
  - Gemfile.lock
176
176
  - Guardfile
177
- - LICENSE
178
177
  - LICENSE.txt
179
178
  - README.md
180
179
  - Rakefile
181
180
  - danger-spec_postfix.gemspec
182
- - danger_plugin.rb
183
- - danger_spec_postfix.rb
184
- - gem_version.rb
185
181
  - lib/danger_plugin.rb
186
182
  - lib/danger_spec_postfix.rb
187
183
  - lib/spec_postfix/gem_version.rb
188
184
  - lib/spec_postfix/plugin.rb
189
- - plugin.rb
190
185
  - spec/spec_helper.rb
191
186
  - spec/spec_postfix_spec.rb
192
- - spec_helper.rb
193
- - spec_postfix/gem_version.rb
194
- - spec_postfix/plugin.rb
195
- - spec_postfix_spec.rb
196
187
  homepage: https://github.com/rambler-digital-solutions/danger-spec_postfix
197
188
  licenses:
198
189
  - MIT
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Rambler Digital Solutions
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/danger_plugin.rb DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_postfix/plugin'
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_postfix/gem_version'
data/gem_version.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SpecPostfix
4
- VERSION = '0.0.1'
5
- end
data/plugin.rb DELETED
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/configurable'
4
-
5
- module Danger
6
- # Check that all test files in spec/ folder have `_spec` postfix.
7
- # Results are passed out as a string with warning.
8
- #
9
- # @example Running linter
10
- #
11
- # # Runs a linter
12
- # spec_postfix.lint
13
- #
14
- class DangerSpecPostfix < Plugin
15
- # Lints the test files. Will fail if any has no '_spec' postfix.
16
- # Generates a `string` with warning.
17
- #
18
- # @param [String] files
19
- # A globbed string which should return the files that you want to lint, defaults to nil.
20
- # if nil, modified and added files from the diff will be used.
21
- # @return [void]
22
- #
23
- def self.configuration
24
- @configuration ||= Configuration.new
25
- end
26
-
27
- def self.configure
28
- yield configuration
29
- end
30
-
31
- def lint
32
- changed_files.select { |f| f.match?(%r{^spec/.*rb$}) }
33
- .reject { |f| f.end_with?('_spec.rb') }
34
- .reject { |f| DangerSpecPostfix.configuration.exceptions.any? { |e| f.start_with?(e) } }
35
- .each { |f| warn(warning_generator(f)) }
36
- end
37
-
38
- private
39
-
40
- def changed_files
41
- (git.modified_files + git.added_files)
42
- end
43
-
44
- def warning_generator(file)
45
- "Tests should have `_spec` postfix: #{file}"
46
- end
47
- end
48
-
49
- class DangerSpecPostfix::Configuration
50
- include ::ActiveSupport::Configurable
51
-
52
- config_accessor(:exceptions) { ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb'] }
53
- end
54
- end
data/spec_helper.rb DELETED
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'pathname'
4
- ROOT = Pathname.new(File.expand_path('..', __dir__))
5
- $:.unshift("#{ROOT}lib")
6
- $:.unshift("#{ROOT}spec")
7
-
8
- require 'bundler/setup'
9
- require 'pry'
10
-
11
- require 'rspec'
12
- require 'danger'
13
-
14
- if `git remote -v` == ''
15
- puts 'You cannot run tests without setting a local git remote on this repo'
16
- puts "It's a weird side-effect of Danger's internals."
17
- exit(0)
18
- end
19
-
20
- # Use coloured output, it's the best.
21
- RSpec.configure do |config|
22
- config.filter_gems_from_backtrace 'bundler'
23
- config.color = true
24
- config.tty = true
25
- end
26
-
27
- require 'danger_plugin'
28
-
29
- # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
30
- # If you are expanding these files, see if it's already been done ^.
31
-
32
- # A silent version of the user interface,
33
- # it comes with an extra function `.string` which will
34
- # strip all ANSI colours from the string.
35
-
36
- # rubocop:disable Lint/NestedMethodDefinition
37
- def testing_ui
38
- @output = StringIO.new
39
- def @output.winsize
40
- [20, 9999]
41
- end
42
-
43
- cork = Cork::Board.new(out: @output)
44
- def cork.string
45
- out.string.gsub(/\e\[([;\d]+)?m/, '')
46
- end
47
- cork
48
- end
49
- # rubocop:enable Lint/NestedMethodDefinition
50
-
51
- # Example environment (ENV) that would come from
52
- # running a PR on TravisCI
53
- def testing_env
54
- {
55
- 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
56
- 'TRAVIS_PULL_REQUEST' => '800',
57
- 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
58
- 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
59
- 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
60
- }
61
- end
62
-
63
- # A stubbed out Dangerfile for use in tests
64
- def testing_dangerfile
65
- env = Danger::EnvironmentManager.new(testing_env)
66
- Danger::Dangerfile.new(env, testing_ui)
67
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SpecPostfix
4
- VERSION = '0.0.1'
5
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/configurable'
4
-
5
- module Danger
6
- # Check that all test files in spec/ folder have `_spec` postfix.
7
- # Results are passed out as a string with warning.
8
- #
9
- # @example Running linter
10
- #
11
- # # Runs a linter
12
- # spec_postfix.lint
13
- #
14
- class DangerSpecPostfix < Plugin
15
- # Lints the test files. Will fail if any has no '_spec' postfix.
16
- # Generates a `string` with warning.
17
- #
18
- # @param [String] files
19
- # A globbed string which should return the files that you want to lint, defaults to nil.
20
- # if nil, modified and added files from the diff will be used.
21
- # @return [void]
22
- #
23
- def self.configuration
24
- @configuration ||= Configuration.new
25
- end
26
-
27
- def self.configure
28
- yield configuration
29
- end
30
-
31
- def lint
32
- changed_files.select { |f| f.match?(%r{^spec/.*rb$}) }
33
- .reject { |f| f.end_with?('_spec.rb') }
34
- .reject { |f| DangerSpecPostfix.configuration.exceptions.any? { |e| f.start_with?(e) } }
35
- .each { |f| warn(warning_generator(f)) }
36
- end
37
-
38
- private
39
-
40
- def changed_files
41
- (git.modified_files + git.added_files)
42
- end
43
-
44
- def warning_generator(file)
45
- "Tests should have `_spec` postfix: #{file}"
46
- end
47
- end
48
-
49
- class DangerSpecPostfix::Configuration
50
- include ::ActiveSupport::Configurable
51
-
52
- config_accessor(:exceptions) { ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb'] }
53
- end
54
- end
data/spec_postfix_spec.rb DELETED
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('spec_helper', __dir__)
4
-
5
- module Danger
6
- describe Danger::DangerSpecPostfix do
7
- it 'is a plugin' do
8
- expect(described_class.new(nil)).to be_a Danger::Plugin
9
- end
10
-
11
- describe 'with Dangerfile' do
12
- let(:file_path) { nil }
13
-
14
- before do
15
- @spec_postfix = testing_dangerfile.spec_postfix
16
-
17
- allow(@spec_postfix.git).to receive(:added_files).and_return([])
18
- allow(@spec_postfix.git).to receive(:modified_files).and_return([file_path])
19
- end
20
-
21
- subject do
22
- @spec_postfix.lint
23
- @spec_postfix.status_report[:warnings]
24
- end
25
-
26
- context 'with _spec' do
27
- let(:file_path) { 'spec/models/my_test_spec.rb' }
28
-
29
- it { is_expected.to be_empty }
30
- end
31
-
32
- context 'with no _spec' do
33
- let(:file_path) { 'spec/models/my_test.rb' }
34
-
35
- it { is_expected.to eq(["Tests should have `_spec` postfix: #{file_path}"]) }
36
- end
37
-
38
- context 'when is irrelevant (exceptions)' do
39
- before do
40
- described_class.configure do |config|
41
- config.exceptions = 'not_tests/'
42
- end
43
- end
44
-
45
- let(:file_path) { 'not_tests/factory.rb' }
46
-
47
- it { is_expected.to be_empty }
48
- end
49
- end
50
- end
51
- end