chutney 2.1.1 → 2.2.1

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: 2da8d4d9f8b99fbedf8ed3b2407e5ec9024496258f86cd69fb76d35699b4ffa4
4
- data.tar.gz: 1821ce09b96bc45203e1a65abac9d5c042bca5036933feda9c066c0ff852ede6
3
+ metadata.gz: ad43c930f710e8cac21960ff14f31da2fb4fe373ed2153fa3ad238b317ebaedd
4
+ data.tar.gz: 84e96dd0222e18b3ba9f5235e81598accc0e254f1997211c69d7b6fb19532957
5
5
  SHA512:
6
- metadata.gz: 3adad450052c2008c3a1db8f82e65893c39605592b72ce676e9b3973fd19f6f2812a949ac5fa375909277298c12115e94771b7dcee06b34dc09362f415af16da
7
- data.tar.gz: ebb9e4d1ea6842131863666ea4362dfc3e94c50525b1444c75e5f8b662c3bd340481d4a8bb00b265991dec0546aab0017e3f86d3a76a850738fbf4407cc68d32
6
+ metadata.gz: 7d26227a05a2087610a64557529f85b2b26afca8b3c273a63203710a65b8640497f7bf5f1aeb19c7572af2b2d4f2487b3e1eb6cf372c7f53bf00a526acd35260
7
+ data.tar.gz: a1f32beace478affe4d3ce7a270f9bd411567b9adb421aef0279b495824cdb35236915f7ea8f388b91d826a62a4cb0040041847694679653d4ebc9e0cb7bb665
@@ -12,6 +12,8 @@ BackgroundRequiresMultipleScenarios:
12
12
  Enabled: true
13
13
  BadScenarioName:
14
14
  Enabled: true
15
+ EmptyFeatureFile:
16
+ Enabled: true
15
17
  FileNameDiffersFeatureName:
16
18
  Enabled: true
17
19
  GivensAfterBackground:
@@ -30,6 +30,9 @@ Chutney enforces its rules with the linters. These are:
30
30
  [BadScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/bad_scenario_name.feature)
31
31
  : You should avoid using words like 'test' or 'check' in your scenario names, instead you should define the behaviour of your system.
32
32
 
33
+ [EmptyFeatureFile](https://github.com/BillyRuffian/chutney/blob/master/features/empty_feature_file.feature)
34
+ : The feature should have content and should avoid committing empty features to repositories.
35
+
33
36
  [FileNameDiffersFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/file_name_differs_feature_name.feature)
34
37
  : The feature should have a name that follows the file name.
35
38
 
@@ -8,6 +8,7 @@ require 'chutney/linter/avoid_typographers_quotes'
8
8
  require 'chutney/linter/background_does_more_than_setup'
9
9
  require 'chutney/linter/background_requires_multiple_scenarios'
10
10
  require 'chutney/linter/bad_scenario_name'
11
+ require 'chutney/linter/empty_feature_file'
11
12
  require 'chutney/linter/file_name_differs_feature_name'
12
13
  require 'chutney/linter/givens_after_background'
13
14
  require 'chutney/linter/invalid_file_name'
@@ -46,7 +47,7 @@ module Chutney
46
47
  attr_accessor :verbose
47
48
  attr_reader :files
48
49
  attr_reader :results
49
-
50
+
50
51
  def_delegators :@files, :<<, :clear, :delete, :include?
51
52
 
52
53
  def initialize(*files)
@@ -57,7 +58,7 @@ module Chutney
57
58
 
58
59
  I18n.load_path << i18n_paths
59
60
  end
60
-
61
+
61
62
  def configuration
62
63
  unless @config
63
64
  default_file = [File.expand_path('..', __dir__), '**/config', 'chutney.yml']
@@ -66,11 +67,11 @@ module Chutney
66
67
  end
67
68
  @config
68
69
  end
69
-
70
+
70
71
  def configuration=(config)
71
72
  @config = config
72
73
  end
73
-
74
+
74
75
  def analyse
75
76
  files.each do |f|
76
77
  lint(f)
@@ -80,23 +81,23 @@ module Chutney
80
81
  # alias for non-british English
81
82
  # https://dictionary.cambridge.org/dictionary/english/analyse
82
83
  alias analyze analyse
83
-
84
+
84
85
  def linters
85
86
  @linters ||= Linter.descendants.filter { |l| configuration.dig(l.linter_name, 'Enabled') }
86
87
  end
87
-
88
+
88
89
  def linters=(*linters)
89
90
  @linters = linters
90
91
  end
91
-
92
+
92
93
  private
93
-
94
+
94
95
  def parse(text)
95
96
  @parser ||= Gherkin::Parser.new
96
97
  scanner = Gherkin::TokenScanner.new(text)
97
98
  @parser.parse(scanner)
98
99
  end
99
-
100
+
100
101
  def lint(file)
101
102
  parsed = parse(File.read(file))
102
103
  linters.each do |linter_class|
@@ -68,12 +68,12 @@ module Chutney
68
68
  element[:tags].map { |tag| tag[:name][1..-1] }
69
69
  end
70
70
 
71
- def add_issue(message, feature, scenario = nil, step = nil)
71
+ def add_issue(message, feature = nil, scenario = nil, step = nil)
72
72
  issues << Lint.new(
73
73
  message: message,
74
74
  gherkin_type: type(feature, scenario, step),
75
75
  location: location(feature, scenario, step),
76
- feature: feature[:name],
76
+ feature: feature ? feature[:name] : nil,
77
77
  scenario: scenario ? scenario[:name] : nil,
78
78
  step: step ? step[:text] : nil
79
79
  ).to_h
@@ -82,8 +82,10 @@ module Chutney
82
82
  def location(feature, scenario, step)
83
83
  if step
84
84
  step[:location]
85
- else
86
- scenario ? scenario[:location] : feature[:location]
85
+ elsif scenario
86
+ scenario[:location]
87
+ else
88
+ feature ? feature[:location] : 0
87
89
  end
88
90
  end
89
91
 
@@ -0,0 +1,8 @@
1
+ module Chutney
2
+ # service class to lint for Features that have no content
3
+ class EmptyFeatureFile < Linter
4
+ def lint
5
+ add_issue(I18n.t('linters.empty_feature_file')) if feature.nil?
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Chutney
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.2.1'.freeze
3
3
  end
@@ -21,6 +21,8 @@ en:
21
21
  Avoid using Background if you only have a single scenario.
22
22
  bad_scenario_name: >-
23
23
  You should avoid using words like '%{word}' in your scenario names.
24
+ empty_feature_file: >-
25
+ The feature file is empty
24
26
  file_name_differs_feature_name: >-
25
27
  The name of the feature should reflect the file name. Consider renaming this feature
26
28
  to '%{expected}'.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chutney
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2020-08-10 00:00:00.000000000 Z
14
+ date: 2020-08-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: amatch
@@ -247,6 +247,7 @@ files:
247
247
  - lib/chutney/linter/background_does_more_than_setup.rb
248
248
  - lib/chutney/linter/background_requires_multiple_scenarios.rb
249
249
  - lib/chutney/linter/bad_scenario_name.rb
250
+ - lib/chutney/linter/empty_feature_file.rb
250
251
  - lib/chutney/linter/file_name_differs_feature_name.rb
251
252
  - lib/chutney/linter/givens_after_background.rb
252
253
  - lib/chutney/linter/invalid_file_name.rb