danger-spec_postfix 0.0.1 → 0.0.2

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: 7e736b77f25af05815d0056f34d6f08cf661b778d2eff55666bdec6aa3609943
4
+ data.tar.gz: 91597c48664c538ff8610390155d172013a6fe49f00016a8fed348e12b72312e
5
5
  SHA512:
6
- metadata.gz: e8129452944e17e50dd6821a47ec71adf77b9796cd896c5a9eb86540838dcb37586c0dd80961a5bf7a7cb95632a31799b0d393c6d996a9b89e1813d6114372a8
7
- data.tar.gz: 2ba88f4ccc36da3eff3902f2e0c85bb72899b331ca5dbf4d9d88b74518a41679cbf2f4071bc6395f348a558c957723e46e0ef412bdcfcc10cc697a9641a82ae1
6
+ metadata.gz: 99ea9aed38ed6d1439fdcd1abb4bfa18a83a5ee04a049a94c6286d7e6f7b45a0a11a0fbc51e24ffe3182aedd5e1d9e190eccd4394e875cbbbad469ccaf91e36b
7
+ data.tar.gz: 073f9ad0dabe33fc140126b7091d8caf63695235e8ba5125bc6f867e6d073d6a7bcd4371d4352fba7d986a790c6dd48b3c8ba0c7c89392b9fcaa758956491fbf
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.2)
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']
data/gem_version.rb CHANGED
@@ -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.2'
5
5
  end
@@ -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.2'
5
5
  end
@@ -2,37 +2,39 @@
2
2
 
3
3
  require 'active_support/configurable'
4
4
 
5
+ # Adding plugin
5
6
  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
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
26
18
 
27
- def self.configure
28
- yield configuration
19
+ config_accessor(:spec_postfix_exceptions) do
20
+ ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb']
29
21
  end
22
+ end
30
23
 
24
+ # Lints the test files. Will fail if any has no '_spec' postfix.
25
+ # Generates a `string` with warning.
26
+ #
27
+ # @param [String] files
28
+ # A globbed string which should return the files that you want to lint, defaults to nil.
29
+ # if nil, modified and added files from the diff will be used.
30
+ # @return [void]
31
+ #
32
+ class DangerSpecPostfix < Plugin
31
33
  def lint
32
34
  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)) }
35
+ .reject { |f| f.end_with?('_spec.rb') }
36
+ .reject { |f| Danger.configuration.spec_postfix_exceptions.any? { |e| f.start_with?(e) } }
37
+ .each { |f| warn(warning_generator(f)) }
36
38
  end
37
39
 
38
40
  private
@@ -45,10 +47,4 @@ module Danger
45
47
  "Tests should have `_spec` postfix: #{file}"
46
48
  end
47
49
  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
50
  end
data/plugin.rb CHANGED
@@ -30,9 +30,9 @@ module Danger
30
30
 
31
31
  def lint
32
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)) }
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
36
  end
37
37
 
38
38
  private
@@ -46,9 +46,13 @@ module Danger
46
46
  end
47
47
  end
48
48
 
49
- class DangerSpecPostfix::Configuration
50
- include ::ActiveSupport::Configurable
49
+ class DangerSpecPostfix
50
+ class Configuration
51
+ include ::ActiveSupport::Configurable
51
52
 
52
- config_accessor(:exceptions) { ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb'] }
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
53
57
  end
54
58
  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'
@@ -37,8 +37,8 @@ module Danger
37
37
 
38
38
  context 'when is irrelevant (exceptions)' do
39
39
  before do
40
- described_class.configure do |config|
41
- config.exceptions = 'not_tests/'
40
+ Danger.configure do |config|
41
+ config.spec_postfix_exceptions = 'not_tests/'
42
42
  end
43
43
  end
44
44
 
data/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'
@@ -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.2'
5
5
  end
@@ -30,9 +30,9 @@ module Danger
30
30
 
31
31
  def lint
32
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)) }
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
36
  end
37
37
 
38
38
  private
@@ -46,9 +46,13 @@ module Danger
46
46
  end
47
47
  end
48
48
 
49
- class DangerSpecPostfix::Configuration
50
- include ::ActiveSupport::Configurable
49
+ class DangerSpecPostfix
50
+ class Configuration
51
+ include ::ActiveSupport::Configurable
51
52
 
52
- config_accessor(:exceptions) { ['spec/shared_examples/', 'spec/factories/', 'spec/support/', 'spec/rails_helper.rb', 'spec/spec_helper.rb'] }
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
53
57
  end
54
58
  end
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Udalov