chutney 2.0.1 → 2.1.1

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: 51d477584ca7861eb03abec1027aa9aff17b19d54dbfae4af34d7c05f5e8fd28
4
- data.tar.gz: 7e7e9d0dc70387ac248718b740220d154331160a9a00da1e1f95e5ec80355497
3
+ metadata.gz: 2da8d4d9f8b99fbedf8ed3b2407e5ec9024496258f86cd69fb76d35699b4ffa4
4
+ data.tar.gz: 1821ce09b96bc45203e1a65abac9d5c042bca5036933feda9c066c0ff852ede6
5
5
  SHA512:
6
- metadata.gz: 04a2ee72ce98367b15f8686397def58751e82e7694769739a916e78a678955cd263235f80bc06f78f1a425cef84d520b52fb86028b814a5e4735bf901d269ff2
7
- data.tar.gz: 0e11405a6cbad626ee2d599e86fa7b284b11b448fa207e9e85c0050d487db3f2a34b26bfe4f732960e50bbb3543d855a8ce86e4b72e4075feec73234e5297823
6
+ metadata.gz: 3adad450052c2008c3a1db8f82e65893c39605592b72ce676e9b3973fd19f6f2812a949ac5fa375909277298c12115e94771b7dcee06b34dc09362f415af16da
7
+ data.tar.gz: ebb9e4d1ea6842131863666ea4362dfc3e94c50525b1444c75e5f8b662c3bd340481d4a8bb00b265991dec0546aab0017e3f86d3a76a850738fbf4407cc68d32
data/.rufo ADDED
@@ -0,0 +1 @@
1
+ quote_style :single
data/README.md CHANGED
@@ -12,10 +12,11 @@
12
12
  <div align="center">
13
13
 
14
14
  [![Gem Version](https://badge.fury.io/rb/chutney.svg)](https://badge.fury.io/rb/chutney)
15
+ [![Downloads](https://img.shields.io/gem/dt/chutney)](https://rubygems.org/gems/chutney)
15
16
  ![CircleCI branch](https://img.shields.io/circleci/project/github/BillyRuffian/chutney/master.svg?style=flat-square)
16
17
  [![CodeFactor](https://www.codefactor.io/repository/github/billyruffian/chutney/badge?style=flat-square)](https://www.codefactor.io/repository/github/billyruffian/chutney)
17
18
  ![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/BillyRuffian/chutney.svg?style=flat-square)
18
19
 
19
20
  </div>
20
21
 
21
- Read the documentation [here](https://billyruffian.github.io/chutney/).
22
+ Read the documentation [here](https://billyruffian.github.io/chutney/).
@@ -51,10 +51,11 @@ Gem::Specification.new do |spec|
51
51
 
52
52
  spec.add_development_dependency 'coveralls', '~> 0.8'
53
53
  spec.add_development_dependency 'cucumber', '~> 3.0'
54
+ spec.add_development_dependency 'pry-byebug', '~> 3.0'
54
55
  spec.add_development_dependency 'rake', '~> 13.0'
55
56
  spec.add_development_dependency 'rerun', '~> 0.13'
56
57
  spec.add_development_dependency 'rspec-expectations', '~> 3.0'
57
- spec.add_development_dependency 'rubocop', '~> 0.79.0'
58
+ spec.add_development_dependency 'rubocop', '~> 0.89.0'
58
59
  spec.add_development_dependency 'rspec', '~> 3.8'
59
60
 
60
61
  end
@@ -4,6 +4,8 @@ AvoidFullStop:
4
4
  Enabled: true
5
5
  AvoidScripting:
6
6
  Enabled: true
7
+ AvoidTypographersQuotes:
8
+ Enabled: true
7
9
  BackgroundDoesMoreThanSetup:
8
10
  Enabled: true
9
11
  BackgroundRequiresMultipleScenarios:
@@ -5,7 +5,7 @@ nav_order: 1
5
5
  permalink: /
6
6
  ---
7
7
 
8
- # Best practice for your Cucumber feature files
8
+ # Best practice for Cucumber
9
9
  {: .fs-9 }
10
10
 
11
11
 
@@ -18,4 +18,4 @@ You're trying to follow TDD or ATDD principles, you're writing executable specif
18
18
 
19
19
  Cucumber itself is an awesome tool which bridges with gap between business language, software development language and the language of testers. With all these folks interested, it's easy to write problematic and hard to maintain features. Chutney tries to help with that by having a common set of quality rules for your feature files.
20
20
 
21
- Chutney is able to lint feature files in any spoken language supported by Cucumber 3.
21
+ Chutney is able to lint feature files in any spoken language supported by Cucumber 3.
@@ -9,7 +9,7 @@ nav_order: 2
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'faker_maker', require: false
12
+ gem 'chutney', require: false
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,4 +18,4 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install chutney
21
+ $ gem install chutney
@@ -7,6 +7,6 @@ nav_order: 3
7
7
 
8
8
  # Configuration
9
9
 
10
- Chutney looks for a configuration file in the current directory called `config/chutney.yml`. This configuration mostly switches on individual linters globally, but a few have addition parameters which can be configured (e.g. the maximum characters in a step).
10
+ Chutney looks for a configuration file in the current directory called `config/.chutney.yml`. This configuration mostly switches on individual linters globally, but a few have addition parameters which can be configured (e.g. the maximum characters in a step).
11
11
 
12
- A default configuration can be found [here](https://github.com/BillyRuffian/chutney/blob/master/config/default.yml).
12
+ A default configuration can be found [here](https://github.com/BillyRuffian/chutney/blob/master/config/chutney.yml).
@@ -9,92 +9,95 @@ nav_order: 2
9
9
 
10
10
  Chutney enforces its rules with the linters. These are:
11
11
 
12
- AvoidFullStop
12
+ [AvoidFullStop](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_full_stop.feature)
13
13
  : Don't have a full stop (period) at the end of step because it makes step reuse really hard.
14
14
 
15
- AvoidOutlineForSingleExample
15
+ [AvoidOutlineForSingleExample](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_outline_for_single_example.feature)
16
16
  : If you only have a single example in your example table, use a plain-old scenario instead.
17
17
 
18
- AvoidScripting
18
+ [AvoidScripting](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_scripting.feature)
19
19
  : You have a lot of steps, are you sure you're not scripting the scenario when you should be specifying the behaviour of the system?
20
20
 
21
- BackgroundDoesMoreThanSetup
21
+ [AvoidTypographersQuotes](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_typographers_quotes.feature)
22
+ : Cutting and pasting from Word documents? Is that pasting in curly-quotes instead of neutral ones you would type on a keyboard? Are you sure that's what you want?
23
+
24
+ [BackgroundDoesMoreThanSetup](https://github.com/BillyRuffian/chutney/blob/master/features/background_does_more_than_setup.feature)
22
25
  : Background in feature files should only do setup activity and so they should only contain `Given` steps.
23
26
 
24
- BackgroundRequiresMultipleScenarios
27
+ [BackgroundRequiresMultipleScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/background_requires_multiple_scenarios.feature)
25
28
  : If you only have one scenario, don't bother having a Background section.
26
29
 
27
- BadScenarioName
30
+ [BadScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/bad_scenario_name.feature)
28
31
  : You should avoid using words like 'test' or 'check' in your scenario names, instead you should define the behaviour of your system.
29
32
 
30
- FileNameDiffersFeatureName
33
+ [FileNameDiffersFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/file_name_differs_feature_name.feature)
31
34
  : The feature should have a name that follows the file name.
32
35
 
33
- GivensAfterBackground
36
+ [GivensAfterBackground](https://github.com/BillyRuffian/chutney/blob/master/features/givens_after_background.feature)
34
37
  : If you have a Background section and your scenario needs more preconditions then it should start immediately with an `And` step and not another `Given`.
35
38
 
36
- InvalidFileName
39
+ [InvalidFileName](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_file_name.feature)
37
40
  : Make sure your file name is in snake case, not mixed case or with spaces.
38
41
 
39
- InvalidStepFlow
42
+ [InvalidStepFlow](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_step_flow.feature)
40
43
  : Your scenarios should follow Given → When → Then, in that order.
41
44
 
42
- MissingExampleName
45
+ [MissingExampleName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_example_name.feature)
43
46
  : If you have more than one example table in your scenario, they should each be given unique names.
44
47
 
45
- MissingFeatureDescription
48
+ [MissingFeatureDescription](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_description.feature)
46
49
  : Your feature should have a value statement. These are usually in the form 'As a... I want.. So that...'.
47
50
 
48
- MissingFeatureName
51
+ [MissingFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_name.feature)
49
52
  : You should give your features a descriptive name.
50
53
 
51
- MissingScenarioName
54
+ [MissingScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_scenario_name.feature)
52
55
  : You should name your scenarios and scenario outlines.
53
56
 
54
- MissingTestAction
57
+ [MissingTestAction](https://github.com/BillyRuffian/chutney/blob/master/features/missing_test_action.feature)
55
58
  : You don't have an action (a `When` step) in your scenario.
56
59
 
57
- MissingVerification
60
+ [MissingVerification](https://github.com/BillyRuffian/chutney/blob/master/features/missing_verification.feature)
58
61
  : You don't have a verification step (a `Then` step) in your scenario.
59
62
 
60
- RequiredTagsStartWith
63
+ [RequiredTagsStartWith](https://github.com/BillyRuffian/chutney/blob/master/features/required_tags_starts_with.feature)
61
64
  : Chutney can enforce a configurable naming prefix for your tags.
62
65
 
63
- SameTagForAllScenarios
66
+ [SameTagForAllScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/same_tag_for_all_scenarios.feature)
64
67
  : You have the same tag for all you scenarios; move the tag to the feature level instead.
65
68
 
66
- ScenarioNamesMatch
69
+ [ScenarioNamesMatch](https://github.com/BillyRuffian/chutney/blob/master/features/scenario_names_match.feature)
67
70
  : Chutney can enforce a naming convention for your scenario names.
68
71
 
69
- TagUsedMultipleTimes
72
+ [TagUsedMultipleTimes](https://github.com/BillyRuffian/chutney/blob/master/features/tag_used_multiple_times.feature)
70
73
  : Chutney can warn if you have used a tag a lot with a feature.
71
74
 
72
- TooClumsy
75
+ [TooClumsy](https://github.com/BillyRuffian/chutney/blob/master/features/too_clumsy.feature)
73
76
  : This is a very long scenario. Consider writing it more concisely.
74
77
 
75
- TooLongStep
78
+ [TooLongStep](https://github.com/BillyRuffian/chutney/blob/master/features/too_long_step.feature)
76
79
  : This is a very long step. Consider writing it more concisely.
77
80
 
78
- TooManyDifferentTags
79
- : This feature has a lot of differnt tags.
81
+ [TooManyDifferentTags](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_different_tags.feature)
82
+ : This feature has a lot of different tags.
80
83
 
81
- TooManySteps
84
+ [TooManySteps](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_steps.feature)
82
85
  : This feature has a lot of steps. Consider writing it more concisely.
83
86
 
84
- TooManyTags
87
+ [TooManyTags](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_tags.feature)
85
88
  : There are a lot of tags in this feature.
86
89
 
87
- UniqueScenarioNames
90
+ [UniqueScenarioNames](https://github.com/BillyRuffian/chutney/blob/master/features/unique_scenario_names.feature)
88
91
  : You have duplicated a scenario name when they should be unique.
89
92
 
90
- UnknownVariable
93
+ [UnknownVariable](https://github.com/BillyRuffian/chutney/blob/master/features/unknown_variable.feature)
91
94
  : You are referencing a variable which doesn't appear to be defined. This is a source of subtle errors.
92
95
 
93
- UnusedVariable
96
+ [UnusedVariable](https://github.com/BillyRuffian/chutney/blob/master/features/unused_variable.feature)
94
97
  : You have a variable which you are not using.
95
98
 
96
- UseBackground
99
+ [UseBackground](https://github.com/BillyRuffian/chutney/blob/master/features/use_background.feature)
97
100
  : You have a setup setup used in all of your scenarios. Move it to a Background section.
98
101
 
99
- UseOutline
102
+ [UseOutline](https://github.com/BillyRuffian/chutney/blob/master/features/use_outline.feature)
100
103
  : You have very similar scenarios. You should consider if they should be combined into a Scenario Outline.
@@ -0,0 +1,14 @@
1
+ # language: em
2
+
3
+ 📚: 🤯
4
+
5
+ As a 👹
6
+ I want to 🏃‍♂️ 🥒
7
+ So that 👁 don't 👀 a 🍆
8
+
9
+ 📕:
10
+ 😐 I am a 🐸
11
+ 🎬 I am 😘 by a 👸
12
+ 🎬 I am 😘 by a 👸
13
+ 🙏 I will ⏎ into a 🤴
14
+
@@ -4,6 +4,7 @@ require 'chutney/linter'
4
4
  require 'chutney/linter/avoid_full_stop'
5
5
  require 'chutney/linter/avoid_outline_for_single_example'
6
6
  require 'chutney/linter/avoid_scripting'
7
+ require 'chutney/linter/avoid_typographers_quotes'
7
8
  require 'chutney/linter/background_does_more_than_setup'
8
9
  require 'chutney/linter/background_requires_multiple_scenarios'
9
10
  require 'chutney/linter/bad_scenario_name'
@@ -21,7 +21,7 @@ module Chutney
21
21
  end
22
22
 
23
23
  def print_report(data)
24
- return unless data.empty?
24
+ return if data.empty?
25
25
 
26
26
  print TTY::Pie.new(data: data, radius: 8, legend: { format: '%<label>s %<name>s %<value>i' })
27
27
  puts
@@ -1,4 +1,5 @@
1
1
  # gherkin utilities
2
+
2
3
  module Chutney
3
4
  # base class for all linters
4
5
  class Linter
@@ -102,7 +103,9 @@ module Chutney
102
103
  end
103
104
  end
104
105
 
105
- def elements
106
+ def elements
107
+ return [] unless feature
108
+
106
109
  if block_given?
107
110
  feature[:children].each do |child|
108
111
  next if off_switch?(child)
@@ -113,7 +116,7 @@ module Chutney
113
116
  feature[:children]
114
117
  end
115
118
  end
116
-
119
+
117
120
  def off_switch?(element = feature)
118
121
  off_switch = element[:tags]
119
122
  .then { |tags| tags || [] }
@@ -0,0 +1,37 @@
1
+ module Chutney
2
+ # service class to lint for avoid scripting
3
+ class AvoidTypographersQuotes < Linter
4
+ TYPOGRAPHER_QUOTES = ["\u201c", "\u201d", "\u2018", "\u2019"].map(&:encode)
5
+
6
+ def lint
7
+ scenarios do |_feature, scenario|
8
+ lint_steps(scenario[:steps])
9
+
10
+ example_count = scenario[:examples]&.length || 0
11
+ next unless example_count.positive?
12
+
13
+ lint_examples(scenario[:examples])
14
+ end
15
+ end
16
+
17
+ def lint_steps(steps)
18
+ steps.each do |step|
19
+ issue(step) if TYPOGRAPHER_QUOTES.any? { |tq| step[:text].include? tq }
20
+ end
21
+ end
22
+
23
+ def lint_examples(examples)
24
+ examples.each do |example|
25
+ example[:tableBody].each do |body|
26
+ body[:cells].each do |cell|
27
+ issue(cell) if TYPOGRAPHER_QUOTES.any? { |tq| cell[:value].include? tq }
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ def issue(location)
34
+ add_issue(I18n.t('linters.avoid_typographers_quotes'), location)
35
+ end
36
+ end
37
+ end
@@ -2,7 +2,7 @@ module Chutney
2
2
  # service class to lint for file name differs feature name
3
3
  class FileNameDiffersFeatureName < Linter
4
4
  def lint
5
- return unless feature.include? :name
5
+ return unless feature&.include?(:name)
6
6
 
7
7
  expected_feature_name = title_case(filename)
8
8
  return if ignore_whitespaces(feature[:name]).casecmp(ignore_whitespaces(expected_feature_name)) == 0
@@ -3,6 +3,8 @@ module Chutney
3
3
  class MissingFeatureDescription < Linter
4
4
  MESSAGE = 'Features should have a description so that its purpose is clear'.freeze
5
5
  def lint
6
+ return unless feature
7
+
6
8
  name = feature.key?(:description) ? feature[:description].strip : ''
7
9
  add_issue(I18n.t('linters.missing_feature_description'), feature) if name.empty?
8
10
  end
@@ -2,6 +2,8 @@ module Chutney
2
2
  # service class to lint for missing feature names
3
3
  class MissingFeatureName < Linter
4
4
  def lint
5
+ return unless feature
6
+
5
7
  name = feature.key?(:name) ? feature[:name].strip : ''
6
8
  add_issue(I18n.t('linters.missing_feature_name'), feature) if name.empty?
7
9
  end
@@ -4,8 +4,8 @@ module Chutney
4
4
  # service class to lint for using same tag on all scenarios
5
5
  class SameTagForAllScenarios < Linter
6
6
  def lint
7
- lint_scenarios if feature.include? :children
8
- lint_examples if feature.include? :children
7
+ lint_scenarios if feature&.include?(:children)
8
+ lint_examples if feature&.include?(:children)
9
9
  end
10
10
 
11
11
  def lint_scenarios
@@ -16,7 +16,7 @@ module Chutney
16
16
  end
17
17
 
18
18
  def all_tags
19
- return [] unless feature.include?(:children)
19
+ return [] unless feature&.include?(:children)
20
20
 
21
21
  tags_for(feature) + feature[:children].map { |scenario| tags_for(scenario) }.flatten
22
22
  end
@@ -36,7 +36,7 @@ module Chutney
36
36
 
37
37
  def gather_scenarios(feature)
38
38
  scenarios = []
39
- return scenarios unless feature.include? :children
39
+ return scenarios if feature.nil? || !feature.include?(:children)
40
40
 
41
41
  feature[:children].each do |scenario|
42
42
  next unless scenario[:type] == :Scenario
@@ -1,3 +1,3 @@
1
1
  module Chutney
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.1'.freeze
3
3
  end
@@ -11,6 +11,10 @@ en:
11
11
  avoid_scripting: >-
12
12
  You have %{count} When steps when you should only have one.
13
13
  Be careful not to add And steps following a When.
14
+ avoid_typographers_quotes: >-
15
+ You are using typographers quotation marks (curly quotes).
16
+ Make sure you intend to use this character and not a neutral quote
17
+ (straight quote) instead.
14
18
  background_does_more_than_setup: >-
15
19
  The Background does more than setup. It should only contain Given steps.
16
20
  background_requires_multiple_scenarios: >-
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chutney
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas
8
8
  - Stefan Rohe
9
9
  - Nishtha Argawal
10
10
  - John Gluck
11
- autorequire:
11
+ autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2020-02-07 00:00:00.000000000 Z
14
+ date: 2020-08-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: amatch
@@ -111,6 +111,20 @@ dependencies:
111
111
  - - "~>"
112
112
  - !ruby/object:Gem::Version
113
113
  version: '3.0'
114
+ - !ruby/object:Gem::Dependency
115
+ name: pry-byebug
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '3.0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '3.0'
114
128
  - !ruby/object:Gem::Dependency
115
129
  name: rake
116
130
  requirement: !ruby/object:Gem::Requirement
@@ -159,14 +173,14 @@ dependencies:
159
173
  requirements:
160
174
  - - "~>"
161
175
  - !ruby/object:Gem::Version
162
- version: 0.79.0
176
+ version: 0.89.0
163
177
  type: :development
164
178
  prerelease: false
165
179
  version_requirements: !ruby/object:Gem::Requirement
166
180
  requirements:
167
181
  - - "~>"
168
182
  - !ruby/object:Gem::Version
169
- version: 0.79.0
183
+ version: 0.89.0
170
184
  - !ruby/object:Gem::Dependency
171
185
  name: rspec
172
186
  requirement: !ruby/object:Gem::Requirement
@@ -195,6 +209,7 @@ files:
195
209
  - ".gitignore"
196
210
  - ".rspec"
197
211
  - ".rubocop.yml"
212
+ - ".rufo"
198
213
  - Gemfile
199
214
  - LICENSE.txt
200
215
  - README.md
@@ -212,6 +227,7 @@ files:
212
227
  - docs/usage/output.md
213
228
  - docs/usage/rules.md
214
229
  - docs/usage/selective_enablement.md
230
+ - examples/emoji.feature
215
231
  - exe/chutney
216
232
  - img/chutney.svg
217
233
  - img/formatters.png
@@ -227,6 +243,7 @@ files:
227
243
  - lib/chutney/linter/avoid_full_stop.rb
228
244
  - lib/chutney/linter/avoid_outline_for_single_example.rb
229
245
  - lib/chutney/linter/avoid_scripting.rb
246
+ - lib/chutney/linter/avoid_typographers_quotes.rb
230
247
  - lib/chutney/linter/background_does_more_than_setup.rb
231
248
  - lib/chutney/linter/background_requires_multiple_scenarios.rb
232
249
  - lib/chutney/linter/bad_scenario_name.rb
@@ -265,7 +282,7 @@ metadata:
265
282
  homepage_uri: https://billyruffian.github.io/chutney/
266
283
  source_code_uri: https://github.com/BillyRuffian/chutney
267
284
  changelog_uri: https://github.com/BillyRuffian/chutney/releases
268
- post_install_message:
285
+ post_install_message:
269
286
  rdoc_options: []
270
287
  require_paths:
271
288
  - lib
@@ -281,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
298
  version: '0'
282
299
  requirements: []
283
300
  rubygems_version: 3.1.2
284
- signing_key:
301
+ signing_key:
285
302
  specification_version: 4
286
303
  summary: A linter for English language Gherkin
287
304
  test_files: []