danger-spec_postfix 0.0.2 → 0.0.4

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: 7e736b77f25af05815d0056f34d6f08cf661b778d2eff55666bdec6aa3609943
4
- data.tar.gz: 91597c48664c538ff8610390155d172013a6fe49f00016a8fed348e12b72312e
3
+ metadata.gz: cb88efc2559876baef00d2c8339fc8c331ba086443dda16b240c04fa669f41b6
4
+ data.tar.gz: da7ccb91e79a960316d896c479e6ea93537f18311d52f257d71cab25a4655e33
5
5
  SHA512:
6
- metadata.gz: 99ea9aed38ed6d1439fdcd1abb4bfa18a83a5ee04a049a94c6286d7e6f7b45a0a11a0fbc51e24ffe3182aedd5e1d9e190eccd4394e875cbbbad469ccaf91e36b
7
- data.tar.gz: 073f9ad0dabe33fc140126b7091d8caf63695235e8ba5125bc6f867e6d073d6a7bcd4371d4352fba7d986a790c6dd48b3c8ba0c7c89392b9fcaa758956491fbf
6
+ metadata.gz: c8dcbd37fc22a213ee5ad3c43b7333f6bbf100c14c6e7da372a83828337e66c89a525bc088609fc195707cc864c4b6cac15714ffaf2a1273352b59a900d6e68f
7
+ data.tar.gz: 51f52ec49624703032a7be42cb99f59a86550bc1e5a7e27da2b9195724030685afbc155f6005de08b85ba1462782d10d9f9e772f48219ebcc60395471ba7c287
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-spec_postfix (0.0.2)
4
+ danger-spec_postfix (0.0.4)
5
5
  danger-plugin-api (~> 1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -12,15 +12,9 @@ Danger plugin to validate sub README mention in main README file
12
12
 
13
13
  spec_postfix.lint
14
14
 
15
- ## Configuration
15
+ You can also pass `exceptions` param in order to skip irrelevant files or directories:
16
16
 
17
- By default some of files and folders are out of scope. You can configure your own custom list of exceptions.
18
-
19
- #config/initializers/danger/danger_spec_postfix.rb
20
-
21
- Danger::DangerSpecPostfix.configure do |config|
22
- config.exceptions = ['rails_helper.rb', 'rails_helper.rb']
23
- end
17
+ spec_postfix.lint(exceptions: ['rails_helper.rb', 'rails_helper.rb', 'spec/factories/', 'spec/support/'])
24
18
 
25
19
  ## Development
26
20
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpecPostfix
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.4'
5
5
  end
@@ -1,39 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/configurable'
4
-
5
- # Adding plugin
6
3
  module Danger
7
- def self.configuration
8
- @configuration ||= Configuration.new
9
- end
10
-
11
- def self.configure
12
- yield configuration
13
- end
14
-
15
- # Adding opportunity to maintain exceptions list for plugin.
16
- class Configuration
17
- include ::ActiveSupport::Configurable
18
-
19
- config_accessor(:spec_postfix_exceptions) do
20
- ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb']
21
- end
22
- end
23
-
24
4
  # Lints the test files. Will fail if any has no '_spec' postfix.
25
5
  # Generates a `string` with warning.
26
6
  #
27
- # @param [String] files
7
+ # @param [Array<String>] files
28
8
  # A globbed string which should return the files that you want to lint, defaults to nil.
29
9
  # if nil, modified and added files from the diff will be used.
30
10
  # @return [void]
31
11
  #
32
12
  class DangerSpecPostfix < Plugin
33
- def lint
13
+ def lint(exceptions: [])
34
14
  changed_files.select { |f| f.match?(%r{^spec/.*rb$}) }
35
15
  .reject { |f| f.end_with?('_spec.rb') }
36
- .reject { |f| Danger.configuration.spec_postfix_exceptions.any? { |e| f.start_with?(e) } }
16
+ .reject { |f| exceptions.any? { |e| f.start_with?(e) } }
37
17
  .each { |f| warn(warning_generator(f)) }
38
18
  end
39
19
 
@@ -36,10 +36,9 @@ module Danger
36
36
  end
37
37
 
38
38
  context 'when is irrelevant (exceptions)' do
39
- before do
40
- Danger.configure do |config|
41
- config.spec_postfix_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.2
4
+ version: 0.0.4
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.2'
5
- end
data/plugin.rb DELETED
@@ -1,58 +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
50
- class Configuration
51
- include ::ActiveSupport::Configurable
52
-
53
- config_accessor(:exceptions) do
54
- ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb']
55
- end
56
- end
57
- end
58
- 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
- $LOAD_PATH.unshift("#{ROOT}lib")
6
- $LOAD_PATH.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.2'
5
- end
@@ -1,58 +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
50
- class Configuration
51
- include ::ActiveSupport::Configurable
52
-
53
- config_accessor(:exceptions) do
54
- ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb']
55
- end
56
- end
57
- end
58
- 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