chutney 3.1.1 → 3.2.0

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: f9a4331eb00fea09babefa186ea7d1e51f13bacbd56cf381cf3fb3d58f293346
4
- data.tar.gz: 16b169146ac5034d46eee9d6858a6b219d854b00d71445a5baca5d6532340b4a
3
+ metadata.gz: 364df4d2dc550c7ee5dbd99b93301c2a83a281b1bf83cc9a00ed201635a919f6
4
+ data.tar.gz: 97e765ad65d122ed5771cbf87e30a774a200b6a03bdc6b7c22c5b515562f8377
5
5
  SHA512:
6
- metadata.gz: 2a8000d183486b9c3201ff22e43fbcfc316d5117b68539aae88b0d22ec2d9d549fdd945c8a4a15393f14d147e53c038923be3aa1dda3483a6066fb58a48ff50f
7
- data.tar.gz: a9a32669fb7ddfd30e742647883a079b654e570b2e6653996a8c9ea26fe1601a402148aabf357e6a79f9150d9f747c8ce6fc80b8036180e3a5b53b3096930950
6
+ metadata.gz: 6821d88c15aa693efff3a4bcde58357a6a066791b39c0354667fc4f6a66d58c607a502e7c97c47df8e286fedf5d5a2d2c8447eab25e2335a75521fca837c9990
7
+ data.tar.gz: 16700a464d8c6700e8d88e83ae387d05502eba187fd281cb0f391fd306155c1cdf118d76eaf0f9f32bfb03a48caf39d79b76031c7ff5a43e0789fe7167f3625a
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ rescue RuntimeError => e
27
27
  end
28
28
 
29
29
  task :spec do
30
- sh 'rspec'
30
+ sh 'bundle exec rspec'
31
31
  end
32
32
 
33
33
  task :cucumber do
data/chutney.gemspec CHANGED
@@ -56,7 +56,7 @@ Gem::Specification.new do |spec|
56
56
 
57
57
 
58
58
  spec.add_development_dependency 'coveralls', '~> 0.8'
59
- spec.add_development_dependency 'cucumber', '~> 6.0'
59
+ spec.add_development_dependency 'cucumber', '~> 7.0'
60
60
  spec.add_development_dependency 'pry-byebug', '~> 3.0'
61
61
  spec.add_development_dependency 'rake', '~> 13.0'
62
62
  spec.add_development_dependency 'rerun', '~> 0.13'
data/config/cucumber.yml CHANGED
@@ -1 +1 @@
1
- default: --publish-quiet
1
+ default: --publish-quiet
@@ -66,7 +66,14 @@ module Chutney
66
66
  end
67
67
 
68
68
  def dialect
69
- @content.feature&.parsing_data&.dig(:language) || 'en'
69
+ parsing_data = @content.feature&.parsing_data
70
+ if !parsing_data.nil? && parsing_data.respond_to?(:language)
71
+ parsing_data.language
72
+ elsif parsing_data
73
+ parsing_data[:language]
74
+ else
75
+ raise UnsupportedCucumberError, 'This version of cucumber is unsupported (langauge detection)'
76
+ end
70
77
  end
71
78
 
72
79
  def tags_for(element)
@@ -79,19 +86,12 @@ module Chutney
79
86
  gherkin_type: type(feature, scenario, item),
80
87
  location: location(feature, scenario, item),
81
88
  feature: feature&.name,
82
- scenario: scenario&.name,
83
- step: item&.parsing_data&.dig(:name)
89
+ scenario: scenario&.name
84
90
  ).to_h
85
91
  end
86
92
 
87
93
  def location(feature, scenario, step)
88
- if step
89
- step.parsing_data[:location]
90
- elsif scenario
91
- scenario.parsing_data.dig(:scenario, :location) || scenario.parsing_data.dig(:background, :location)
92
- else
93
- feature ? feature.parsing_data[:location] : { line: 0, column: 0 }
94
- end
94
+ Locator.locate(feature, scenario, step)
95
95
  end
96
96
 
97
97
  def type(_feature, scenario, step)
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Chutney
4
+ # Utility module to assist in locating the source of parts of a gherkin specification
5
+ module Locator
6
+ module_function
7
+
8
+ def locate(feature, scenario, step)
9
+ if step
10
+ locate_step(step)
11
+ elsif scenario
12
+ locate_scenario(scenario)
13
+ elsif feature
14
+ locate_feature(feature)
15
+ else
16
+ feature
17
+ end
18
+ end
19
+
20
+ def locate_step(step)
21
+ return step.parsing_data.location.to_h if step.parsing_data.respond_to?(:location)
22
+ return step.parsing_data[:location] if step.parsing_data.is_a?(Hash)
23
+
24
+ raise UnsupportedCucumberError, 'This version of cucumber is unsupported (step location)'
25
+ end
26
+
27
+ def locate_scenario(scenario)
28
+ parsing_data = scenario.parsing_data
29
+
30
+ if parsing_data.is_a?(Hash)
31
+ parsing_data.dig(:scenario, :location) || parsing_data.dig(:background, :location)
32
+ elsif parsing_data.respond_to?(:scenario)
33
+ (parsing_data.scenario || parsing_data.background).location.to_h
34
+ else
35
+ raise UnsupportedCucumberError, 'This version of cucumber is unsupported (scenario location)'
36
+ end
37
+ end
38
+
39
+ def locate_feature(feature)
40
+ return feature.parsing_data.location.to_h if feature.parsing_data.respond_to?(:location)
41
+ return feature.parsing_data[:location] if feature.parsing_data.is_a?(Hash)
42
+
43
+ raise UnsupportedCucumberError, 'This version of cucumber is unsupported (feature location)'
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chutney
4
- VERSION = '3.1.1'
4
+ VERSION = '3.2.0'
5
5
  end
data/lib/chutney.rb CHANGED
@@ -37,6 +37,7 @@ require 'chutney/linter/unknown_variable'
37
37
  require 'chutney/linter/unused_variable'
38
38
  require 'chutney/linter/use_background'
39
39
  require 'chutney/linter/use_outline'
40
+ require 'chutney/locator'
40
41
  require 'chutney/version'
41
42
 
42
43
  require 'cuke_modeler'
@@ -48,6 +49,8 @@ require 'set'
48
49
  require 'yaml'
49
50
 
50
51
  module Chutney
52
+ class UnsupportedCucumberError < StandardError; end
53
+
51
54
  # gherkin linter
52
55
  class ChutneyLint
53
56
  extend Forwardable
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: 3.1.1
4
+ version: 3.2.0
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: 2021-05-12 00:00:00.000000000 Z
14
+ date: 2021-09-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: amatch
@@ -103,14 +103,14 @@ dependencies:
103
103
  requirements:
104
104
  - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: '6.0'
106
+ version: '7.0'
107
107
  type: :development
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: '6.0'
113
+ version: '7.0'
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: pry-byebug
116
116
  requirement: !ruby/object:Gem::Requirement
@@ -277,6 +277,7 @@ files:
277
277
  - lib/chutney/linter/unused_variable.rb
278
278
  - lib/chutney/linter/use_background.rb
279
279
  - lib/chutney/linter/use_outline.rb
280
+ - lib/chutney/locator.rb
280
281
  - lib/chutney/version.rb
281
282
  - lib/config/locales/en.yml
282
283
  - spec/chutney_spec.rb
@@ -303,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
304
  - !ruby/object:Gem::Version
304
305
  version: '0'
305
306
  requirements: []
306
- rubygems_version: 3.1.4
307
+ rubygems_version: 3.2.22
307
308
  signing_key:
308
309
  specification_version: 4
309
310
  summary: A linter for multi-lingual Gherkin