cucumber-compatibility-kit 14.1.0 → 15.0.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: b3f9fd6f1118a353dcb70d78918104faaec98900794009e98ba4ff451e56b86d
4
- data.tar.gz: 4901fd8909cfc6dd0334be0133edb3b81c3f4667590b6bd1e8807c9ba73de129
3
+ metadata.gz: 67e85c8e27fae29ac90a87e5aeda3ec365687567223cf54bf6bbb6920f53ce79
4
+ data.tar.gz: 320ce4aac15d70ce55ea4ce69e98e2aaf81768b256d095a4ae8c2b481605246f
5
5
  SHA512:
6
- metadata.gz: 2d92235dbbf94e431c6fdf2996df97106156e96d6f229bbc18d5d7b7b93b22c2c4c9f3270a0ce54cd98349715b586a0b428e9d266b6ec72f0d877ff387657cf8
7
- data.tar.gz: 29aaf8c331a5c3a30c025cc6c5aa492d6fc2330098ae21863e331a7531aa996eae0141cfd9ed433b46ccc27c387f4a86997b437c0714d67bd87f690dbc9ad724
6
+ metadata.gz: 374faa473dfd3791017701063fbc5edae7645abc987bff819079caeeaa2c0fb17bb8d40f4d76e6743ffaa3baad8299be4c5a268b5c0954297ab43e1363759b02
7
+ data.tar.gz: 57958f684b2017bac5186b815fbbb347de753e1e3c316288a222885b152f2a624fe98f142b3e479c751def795b46bba75f96840564dd513c8a004e7d90b8ebb1
data/README.md CHANGED
@@ -6,16 +6,15 @@ It aims to validate an implementation of the
6
6
 
7
7
  ## Overview
8
8
 
9
- The kit is composed of features and messages:
9
+ This kit (gem), consists of a set of features, miscellaneous files and messages:
10
10
 
11
- - features, once executed, emit an exhaustive set of Messages as specified by
12
- the protocol
13
- - Messages - serialized as `.ndjson` files - are the reference: a given feature
14
- from the kit, executed using its dedicated step definitions, must emit the
15
- corresponding Messages
16
-
17
- The ruby gem also provides some tools to help in the validation of messages issued
18
- from the execution of the CCK's features.
11
+ - Each area will contain one feature, which, once executed, will emit an exhaustive set of messages
12
+ as specified by the protocol
13
+ - Some of these areas may "also" require miscellaneous files to be used when testing functions
14
+ such as attaching images or documents or reading data from files
15
+ - Each area will contain a set of messages - serialized as a single `.ndjson` file
16
+ This is the reference for the CCK, that a given feature from the kit, when executed using any dedicated
17
+ step definitions, must emit the **exact** corresponding messages
19
18
 
20
19
  ## Installation and Usage
21
20
 
@@ -27,56 +26,48 @@ install it:
27
26
  Then add a spec that could look like this:
28
27
 
29
28
  ```ruby
30
- # spec/cck_spec.rb
29
+ # spec/my_compatibility_checks_spec.rb
31
30
  require 'cucumber-compatibility-kit'
32
31
 
33
- describe 'Cucumber Compatibility Kit' do
34
- let(:cucumber_bin) { './bin/cucumber' }
35
- let(:cucumber_common_args) { '--publish-quiet --profile none --format message' }
36
- let(:cucumber_command) { "#{cucumber_bin} #{cucumber_common_args}" }
32
+ describe 'Cucumber Compatibility Kit', type: :feature do
33
+ let(:cucumber_command) { 'bundle exec cucumber --publish-quiet --profile none --format message' }
37
34
 
38
- examples = Cucumber::CompatibilityKit.gherkin_examples.reject { |example|
39
- example == 'retry'
40
- }
35
+ # Don't run the retry or skipped CCK Examples (For whatever reason)
36
+ examples = CCK::Examples.gherkin.reject { |example| example == 'retry' || example == 'skipped' }
41
37
 
42
38
  examples.each do |example_name|
43
39
  describe "'#{example_name}' example" do
44
40
  include_examples 'cucumber compatibility kit' do
45
41
  let(:example) { example_name }
46
- let(:messages) { `#{cucumber_command} --require #{example_path} #{example_path}` }
42
+ # You will need to specify the relative support code and cck paths
43
+ let(:messages) { `#{cucumber_command} --require #{support_code_path} #{cck_path}` }
47
44
  end
48
45
  end
49
46
  end
50
47
  end
51
-
52
48
  ```
53
49
 
54
- `Cucumber::CompatibilityKit.gherkin_examples` returns an array that list all the
55
- gherkin examples available within the CCK. Here, we want to execute all of them with
56
- the exception of the `retry` one.
50
+ `CCK::Examples.gherkin` will return an array that lists all the gherkin examples available within the CCK.
51
+ Here, we want to execute all of them with the exception of the `retry` and `skipped` ones.
57
52
 
58
- `let(:messages)` executes the cucumber command. `example_path` is provided by the
59
- CCK. It is the path to the folder which contains the feature, and the support code
60
- required to execute the given example. As we use the `--format message` formatter,
61
- `messages` will then contain the messages as a `ndjson` document.
53
+ `let(:messages)` will execute the cucumber command. As we are using the `message` formatter, `messages` will
54
+ then contain the messages as a `ndjson` document with one message per line.
62
55
 
63
- You can use `gem open cucumber-compatibility-kit` in order to take a look on the
64
- features, their support code, and the expected messages.They are available in the
65
- `features` folder within the gem.
56
+ You can use `gem open cucumber-compatibility-kit` in order to take a look at the features and the
57
+ expected messages they should produce. They are available in the `features` folder within the gem.
66
58
 
67
59
  ## More info
68
60
 
69
61
  The Cucumber Compatibility Kit is part of the development tools of [Cucumber](https://cucumber.io).
70
62
  It allows us to make sure that all our implementations are properly supporting our internal protocol
71
- and thus are compabitle with each other and with our common tools like the [html-formatter](https://github.com/cucumber/html-formatter).
63
+ and thus are compatible (and consistent), with each other and our common tools like the [html-formatter](https://github.com/cucumber/html-formatter).
72
64
 
73
- It can be a valuable tool if you are developing integration with cucumber, or your
74
- own implementation of it.
65
+ It can be a valuable tool if you are developing integration with cucumber, or your own implementation of it.
75
66
 
76
67
  Join us on [github/cucumber/compatibility-kit](https://github.com/cucumber/compatibility-kit)
77
68
  to get more help if you need to.
78
69
 
79
- You can also take a look on [cucumber-ruby](https://github.com/cucumber/cucumber-ruby/blob/v8.0.0/spec/cck/cck_spec.rb)
70
+ You can also take a look on [cucumber-ruby](https://github.com/cucumber/cucumber-ruby/blob/v9.2.0/compatibility/cck_spec.rb)
80
71
  to see how the kit is used there.
81
72
 
82
73
  ## Development
@@ -85,6 +76,6 @@ Before building this project locally, the samples must be copied from the `devki
85
76
 
86
77
  ```
87
78
  cd ../devkit
88
- npm run copy-samples
79
+ npm ci && npm run copy-to:ruby
89
80
  cd ../ruby
90
- ```
81
+ ```
@@ -1,44 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'shared_examples'
4
-
5
- module Cucumber
6
- module CompatibilityKit
3
+ module CCK
4
+ module Examples
7
5
  class << self
8
- def all_examples
9
- gherkin_examples + markdown_examples
10
- end
11
-
12
- def gherkin_examples
13
- Dir.entries(examples_path).select do |file_or_folder|
6
+ def gherkin
7
+ Dir.entries(features_folder_location).select do |file_or_folder|
14
8
  next if file_or_folder.start_with?('.')
15
9
 
16
- gherkin_example?(File.join(examples_path, file_or_folder))
10
+ gherkin_example?(File.join(features_folder_location, file_or_folder))
17
11
  end
18
12
  end
19
13
 
20
- def markdown_examples
21
- Dir.entries(examples_path).select do |file_or_folder|
14
+ def markdown
15
+ Dir.entries(features_folder_location).select do |file_or_folder|
22
16
  next if file_or_folder.start_with?('.')
23
17
 
24
- markdown_example?(File.join(examples_path, file_or_folder))
18
+ markdown_example?(File.join(features_folder_location, file_or_folder))
25
19
  end
26
20
  end
27
21
 
28
- def examples_path
29
- File.expand_path("#{File.dirname(__FILE__)}/../../features/")
30
- end
31
-
32
- def example_path(example_name)
33
- path = File.join(examples_path, example_name)
22
+ def feature_code_for(example_name)
23
+ path = File.join(features_folder_location, example_name)
34
24
 
35
25
  return path if File.directory?(path)
36
26
 
37
- raise ArgumentError, "No CCK example exists for #{example_name}"
27
+ raise ArgumentError, "No feature code directory found in gem for CCK example: #{example_name}"
38
28
  end
39
29
 
40
30
  private
41
31
 
32
+ def features_folder_location
33
+ File.expand_path("#{File.dirname(__FILE__)}/../../features/")
34
+ end
35
+
42
36
  def gherkin_example?(example_folder)
43
37
  file_type_in_folder?('.feature', example_folder)
44
38
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'cucumber/cucumber-compatibility-kit'
3
+ require_relative 'cck/examples'
metadata CHANGED
@@ -1,58 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-compatibility-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.1.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurélien Reeves
8
8
  - Aslak Hellesøy
9
9
  - Vincent Prêtre
10
+ - Luke Hill
10
11
  - Cucumber Ltd
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2023-11-10 00:00:00.000000000 Z
15
+ date: 2024-01-08 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: cucumber-messages
18
19
  requirement: !ruby/object:Gem::Requirement
19
20
  requirements:
20
- - - ">="
21
+ - - ">"
21
22
  - !ruby/object:Gem::Version
22
- version: 19.1.2
23
+ version: '20'
23
24
  - - "<"
24
25
  - !ruby/object:Gem::Version
25
- version: '22.1'
26
+ version: '25'
26
27
  type: :runtime
27
28
  prerelease: false
28
29
  version_requirements: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ">="
31
+ - - ">"
31
32
  - !ruby/object:Gem::Version
32
- version: 19.1.2
33
+ version: '20'
33
34
  - - "<"
34
35
  - !ruby/object:Gem::Version
35
- version: '22.1'
36
- - !ruby/object:Gem::Dependency
37
- name: rake
38
- requirement: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '13.0'
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: 13.0.6
46
- type: :runtime
47
- prerelease: false
48
- version_requirements: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '13.0'
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 13.0.6
36
+ version: '25'
56
37
  - !ruby/object:Gem::Dependency
57
38
  name: rspec
58
39
  requirement: !ruby/object:Gem::Requirement
@@ -60,7 +41,7 @@ dependencies:
60
41
  - - "~>"
61
42
  - !ruby/object:Gem::Version
62
43
  version: '3.12'
63
- type: :runtime
44
+ type: :development
64
45
  prerelease: false
65
46
  version_requirements: !ruby/object:Gem::Requirement
66
47
  requirements:
@@ -73,56 +54,42 @@ dependencies:
73
54
  requirements:
74
55
  - - "~>"
75
56
  - !ruby/object:Gem::Version
76
- version: 1.17.0
57
+ version: 1.50.2
77
58
  type: :development
78
59
  prerelease: false
79
60
  version_requirements: !ruby/object:Gem::Requirement
80
61
  requirements:
81
62
  - - "~>"
82
63
  - !ruby/object:Gem::Version
83
- version: 1.17.0
64
+ version: 1.50.2
84
65
  - !ruby/object:Gem::Dependency
85
66
  name: rubocop-performance
86
67
  requirement: !ruby/object:Gem::Requirement
87
68
  requirements:
88
69
  - - "~>"
89
70
  - !ruby/object:Gem::Version
90
- version: 1.7.0
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: 1.7.0
98
- - !ruby/object:Gem::Dependency
99
- name: rubocop-rake
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: 0.5.0
71
+ version: 1.17.1
105
72
  type: :development
106
73
  prerelease: false
107
74
  version_requirements: !ruby/object:Gem::Requirement
108
75
  requirements:
109
76
  - - "~>"
110
77
  - !ruby/object:Gem::Version
111
- version: 0.5.0
78
+ version: 1.17.1
112
79
  - !ruby/object:Gem::Dependency
113
80
  name: rubocop-rspec
114
81
  requirement: !ruby/object:Gem::Requirement
115
82
  requirements:
116
83
  - - "~>"
117
84
  - !ruby/object:Gem::Version
118
- version: 2.0.0
85
+ version: 2.20.0
119
86
  type: :development
120
87
  prerelease: false
121
88
  version_requirements: !ruby/object:Gem::Requirement
122
89
  requirements:
123
90
  - - "~>"
124
91
  - !ruby/object:Gem::Version
125
- version: 2.0.0
92
+ version: 2.20.0
126
93
  description: Kit to check compatibility with official cucumber implementation
127
94
  email: cukebot@cucumber.io
128
95
  executables: []
@@ -132,64 +99,41 @@ files:
132
99
  - README.md
133
100
  - features/attachments/attachments.feature
134
101
  - features/attachments/attachments.feature.ndjson
135
- - features/attachments/attachments.feature.rb
136
102
  - features/attachments/cucumber.jpeg
137
103
  - features/attachments/cucumber.png
138
104
  - features/attachments/document.pdf
139
105
  - features/cdata/cdata.feature
140
106
  - features/cdata/cdata.feature.ndjson
141
- - features/cdata/cdata.feature.rb
142
107
  - features/data-tables/data-tables.feature
143
108
  - features/data-tables/data-tables.feature.ndjson
144
- - features/data-tables/data-tables.feature.rb
145
109
  - features/examples-tables/examples-tables.feature
146
110
  - features/examples-tables/examples-tables.feature.ndjson
147
- - features/examples-tables/examples-tables.feature.rb
148
111
  - features/hooks/cucumber.svg
149
112
  - features/hooks/hooks.feature
150
113
  - features/hooks/hooks.feature.ndjson
151
- - features/hooks/hooks.feature.rb
152
114
  - features/markdown/markdown.feature.md
153
115
  - features/markdown/markdown.feature.md.ndjson
154
116
  - features/minimal/minimal.feature
155
117
  - features/minimal/minimal.feature.ndjson
156
- - features/minimal/minimal.feature.rb
157
118
  - features/parameter-types/parameter-types.feature
158
119
  - features/parameter-types/parameter-types.feature.ndjson
159
- - features/parameter-types/parameter-types.feature.rb
160
120
  - features/pending/pending.feature
161
121
  - features/pending/pending.feature.ndjson
162
- - features/pending/pending.feature.rb
163
122
  - features/retry/retry.arguments.txt
164
123
  - features/retry/retry.feature
165
124
  - features/retry/retry.feature.ndjson
166
- - features/retry/retry.feature.rb
167
125
  - features/rules/rules.feature
168
126
  - features/rules/rules.feature.ndjson
169
- - features/rules/rules.feature.rb
170
127
  - features/skipped/skipped.feature
171
128
  - features/skipped/skipped.feature.ndjson
172
- - features/skipped/skipped.feature.rb
173
129
  - features/stack-traces/stack-traces.feature
174
130
  - features/stack-traces/stack-traces.feature.ndjson
175
- - features/stack-traces/stack-traces.feature.rb
176
131
  - features/undefined/undefined.feature
177
132
  - features/undefined/undefined.feature.ndjson
178
- - features/undefined/undefined.feature.rb
179
133
  - features/unknown-parameter-type/unknown-parameter-type.feature
180
134
  - features/unknown-parameter-type/unknown-parameter-type.feature.ndjson
181
- - features/unknown-parameter-type/unknown-parameter-type.feature.rb
182
- - lib/cck/helpers.rb
183
- - lib/cck/keys_checker.rb
184
- - lib/cck/messages_comparator.rb
135
+ - lib/cck/examples.rb
185
136
  - lib/cucumber-compatibility-kit.rb
186
- - lib/cucumber/cucumber-compatibility-kit.rb
187
- - lib/keys_checker.rb
188
- - lib/messages_comparator.rb
189
- - lib/shared_examples.rb
190
- - spec/cck/keys_checker_spec.rb
191
- - spec/cck/messages_comparator_spec.rb
192
- - spec/cucumber/cucumber-compatibility-kit_spec.rb
193
137
  homepage: https://github.com/cucumber/compatibility-kit
194
138
  licenses:
195
139
  - MIT
@@ -208,18 +152,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
152
  requirements:
209
153
  - - ">="
210
154
  - !ruby/object:Gem::Version
211
- version: '2.5'
155
+ version: '2.6'
212
156
  required_rubygems_version: !ruby/object:Gem::Requirement
213
157
  requirements:
214
158
  - - ">="
215
159
  - !ruby/object:Gem::Version
216
- version: '0'
160
+ version: 3.0.9
217
161
  requirements: []
218
162
  rubygems_version: 3.4.10
219
163
  signing_key:
220
164
  specification_version: 4
221
- summary: cucumber-compatibility-kit-14.1.0
222
- test_files:
223
- - spec/cck/keys_checker_spec.rb
224
- - spec/cck/messages_comparator_spec.rb
225
- - spec/cucumber/cucumber-compatibility-kit_spec.rb
165
+ summary: cucumber-compatibility-kit-15.0.0
166
+ test_files: []
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Cucumber-JVM needs to use a Before hook in order to create attachments
4
- # NB: We should probably try to remove this
5
- Before { nil }
6
-
7
- When('the string {string} is attached as {string}') do |text, media_type|
8
- attach(text, media_type)
9
- end
10
-
11
- When('the string {string} is logged') do |text|
12
- log(text)
13
- end
14
-
15
- When('text with ANSI escapes is logged') do
16
- log("This displays a \x1b[31mr\x1b[0m\x1b[91ma\x1b[0m\x1b[33mi\x1b[0m\x1b[32mn\x1b[0m\x1b[34mb\x1b[0m\x1b[95mo\x1b[0m\x1b[35mw\x1b[0m")
17
- end
18
-
19
- When('the following string is attached as {string}:') do |media_type, doc_string|
20
- attach(doc_string, media_type)
21
- end
22
-
23
- When('an array with {int} bytes is attached as {string}') do |size, media_type|
24
- data = (0..size - 1).map { |i| [i].pack('C') }.join
25
- attach(data, media_type)
26
- end
27
-
28
- When('a JPEG image is attached') do
29
- attach(File.open("#{__dir__}/cucumber.jpeg"), 'image/jpeg')
30
- end
31
-
32
- When('a PNG image is attached') do
33
- attach(File.open("#{__dir__}/cucumber.png"), 'image/png')
34
- end
35
-
36
- When('a PDF document is attached and renamed') do
37
- attach(File.open("#{__dir__}/document.pdf"), 'document/pdf', 'renamed.pdf')
38
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('I have {int} <![CDATA[cukes]]> in my belly') do |_cuke_count|
4
- # no-op
5
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- When('the following table is transposed:') do |table|
4
- @transposed = table.transpose
5
- end
6
-
7
- Then('it should be:') do |expected|
8
- @transposed.diff!(expected)
9
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('there are {int} cucumbers') do |initial_count|
4
- @count = initial_count
5
- end
6
-
7
- When('I eat {int} cucumbers') do |eat_count|
8
- @count -= eat_count
9
- end
10
-
11
- Then('I should have {int} cucumbers') do |expected_count|
12
- expect(@count).to eq(expected_count)
13
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Before do
4
- # no-op
5
- end
6
-
7
- Before(name: 'A named hook') do
8
- # no-op
9
- end
10
-
11
- When('a step passes') do
12
- # no-op
13
- end
14
-
15
- When('a step fails') do
16
- raise 'Exception in step'
17
- end
18
-
19
- After do
20
- # no-op
21
- end
22
-
23
- After('@some-tag or @some-other-tag') do
24
- raise 'Exception in conditional hook'
25
- end
26
-
27
- After('@with-attachment') do
28
- attach(File.open("#{__dir__}/cucumber.svg"), 'image/svg+xml')
29
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('I have {int} cukes in my belly') do |_cuke_count|
4
- # no-op
5
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Flight
4
- attr_reader :from, :to
5
-
6
- def initialize(from, to)
7
- @from = from
8
- @to = to
9
- end
10
- end
11
-
12
- ParameterType(
13
- name: 'flight',
14
- regexp: /([A-Z]{3})-([A-Z]{3})/,
15
- transformer: ->(from, to) { Flight.new(from, to) }
16
- )
17
-
18
- Given('{flight} has been delayed') do |flight|
19
- expect(flight.from).to eq('LHR')
20
- expect(flight.to).to eq('CDG')
21
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('an implemented non-pending step') do
4
- # no-op
5
- end
6
-
7
- Given('an implemented step that is skipped') do
8
- # no-op
9
- end
10
-
11
- Given('an unimplemented pending step') do
12
- pending('')
13
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('a step that always passes') do
4
- # no-op
5
- end
6
-
7
- second_time_pass = 0
8
- Given('a step that passes the second time') do
9
- second_time_pass += 1
10
- raise 'Exception in step' if second_time_pass < 2
11
- end
12
-
13
- third_time_pass = 0
14
- Given('a step that passes the third time') do
15
- third_time_pass += 1
16
- raise 'Exception in step' if third_time_pass < 3
17
- end
18
-
19
- Given('a step that always fails') do
20
- raise 'Exception in step'
21
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('the customer has {int} cents') do |money|
4
- @money = money
5
- end
6
-
7
- Given('there are chocolate bars in stock') do
8
- @stock = ['Mars']
9
- end
10
-
11
- Given('there are no chocolate bars in stock') do
12
- @stock = []
13
- end
14
-
15
- When('the customer tries to buy a {int} cent chocolate bar') do |price|
16
- @chocolate = @stock.pop if @money >= price
17
- end
18
-
19
- Then('the sale should not happen') do
20
- expect(@chocolate).to be_nil
21
- end
22
-
23
- Then('the sale should happen') do
24
- expect(@chocolate).not_to be_nil
25
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Before('@skip') do
4
- skip_this_scenario('')
5
- end
6
-
7
- Given('a step that does not skip') do
8
- # no-op
9
- end
10
-
11
- Given('a step that is skipped') do
12
- # no-op
13
- end
14
-
15
- Given('I skip a step') do
16
- skip_this_scenario('')
17
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- When('a step throws an exception') do
4
- raise 'BOOM'
5
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('an implemented step') do
4
- # no-op
5
- end
6
-
7
- Given('a step that will be skipped') do
8
- # no-op
9
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('{airport} is closed because of a strike') do |_airport|
4
- raise 'Should not be called because airport parameter type has not been defined'
5
- end
data/lib/cck/helpers.rb DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CCK
4
- module Helpers
5
- def message_type(message)
6
- message.to_h.each do |key, value|
7
- return key unless value.nil?
8
- end
9
- end
10
- end
11
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CCK
4
- class KeysChecker
5
- def self.compare(detected, expected)
6
- new(detected, expected).compare
7
- end
8
-
9
- attr_reader :detected, :expected
10
-
11
- def initialize(detected, expected)
12
- @detected = detected
13
- @expected = expected
14
- end
15
-
16
- def compare
17
- return [] if identical_keys?
18
-
19
- errors << "Detected extra keys in message #{message_name}: #{extra_keys}" if extra_keys.any?
20
- errors << "Missing keys in message #{message_name}: #{missing_keys}" if missing_keys.any?
21
- errors
22
- rescue StandardError => e
23
- ["Unexpected error: #{e.message}"]
24
- end
25
-
26
- private
27
-
28
- def detected_keys
29
- @detected_keys ||= ordered_uniq_hash_keys(detected)
30
- end
31
-
32
- def expected_keys
33
- @expected_keys ||= ordered_uniq_hash_keys(expected)
34
- end
35
-
36
- def identical_keys?
37
- detected_keys == expected_keys
38
- end
39
-
40
- def missing_keys
41
- (expected_keys - detected_keys).reject { |key| meta_message? && key == :ci }
42
- end
43
-
44
- def extra_keys
45
- (detected_keys - expected_keys).reject { |key| meta_message? && key == :ci }
46
- end
47
-
48
- def meta_message?
49
- detected.instance_of?(Cucumber::Messages::Meta)
50
- end
51
-
52
- def message_name
53
- detected.class.name
54
- end
55
-
56
- def ordered_uniq_hash_keys(object)
57
- object.to_h(reject_nil_values: true).keys.sort
58
- end
59
-
60
- def errors
61
- @errors ||= []
62
- end
63
- end
64
- end
@@ -1,97 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'keys_checker'
4
- require_relative 'helpers'
5
-
6
- module CCK
7
- class MessagesComparator
8
- include Helpers
9
-
10
- def initialize(detected, expected)
11
- compare(detected, expected)
12
- end
13
-
14
- def errors
15
- all_errors.flatten
16
- end
17
-
18
- private
19
-
20
- def compare(detected, expected)
21
- detected_by_type = messages_by_type(detected)
22
- expected_by_type = messages_by_type(expected)
23
-
24
- detected_by_type.each_key do |type|
25
- compare_list(detected_by_type[type], expected_by_type[type])
26
- rescue StandardError => e
27
- all_errors << "Error while comparing #{type}: #{e.message}"
28
- end
29
- end
30
-
31
- def messages_by_type(messages)
32
- by_type = Hash.new { |h, k| h[k] = [] }
33
- messages.each do |msg|
34
- by_type[message_type(msg)] << remove_envelope(msg)
35
- end
36
- by_type
37
- end
38
-
39
- def remove_envelope(message)
40
- message.send(message_type(message))
41
- end
42
-
43
- def compare_list(detected, expected)
44
- detected.each_with_index do |message, index|
45
- compare_message(message, expected[index])
46
- end
47
- end
48
-
49
- def compare_message(detected, expected)
50
- return if not_message?(detected)
51
- return if ignorable?(detected)
52
- return if incomparable?(detected)
53
-
54
- all_errors << CCK::KeysChecker.compare(detected, expected)
55
- compare_sub_messages(detected, expected)
56
- end
57
-
58
- def not_message?(detected)
59
- !detected.is_a?(Cucumber::Messages::Message)
60
- end
61
-
62
- # These messages we need to ignore because they are too large or they feature timestamps which always vary
63
- def ignorable?(detected)
64
- too_large_message?(detected) || time_message?(detected)
65
- end
66
-
67
- def too_large_message?(detected)
68
- detected.is_a?(Cucumber::Messages::GherkinDocument) || detected.is_a?(Cucumber::Messages::Pickle)
69
- end
70
-
71
- def time_message?(detected)
72
- detected.is_a?(Cucumber::Messages::Timestamp) || detected.is_a?(Cucumber::Messages::Duration)
73
- end
74
-
75
- # These messages we need to ignore because they are often not of identical shape/value
76
- def incomparable?(detected)
77
- detected.is_a?(Cucumber::Messages::Ci) || detected.is_a?(Cucumber::Messages::Git)
78
- end
79
-
80
- def compare_sub_messages(detected, expected)
81
- return unless expected.respond_to? :to_h
82
-
83
- expected.to_h.each_key do |key|
84
- value = expected.send(key)
85
- if value.is_a?(Array)
86
- compare_list(detected.send(key), value)
87
- else
88
- compare_message(detected.send(key), value)
89
- end
90
- end
91
- end
92
-
93
- def all_errors
94
- @all_errors ||= []
95
- end
96
- end
97
- end
data/lib/keys_checker.rb DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'cck/keys_checker'
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'cck/messages_comparator'
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'rspec'
5
- require 'cucumber/messages'
6
-
7
- require 'messages_comparator'
8
- require 'keys_checker'
9
-
10
- RSpec.shared_examples 'cucumber compatibility kit' do
11
- include CCK::Helpers
12
-
13
- # NOTE: to use those examples, you need to define:
14
- # let(:example) { } # the name of the example to test
15
- # let(:messages) { } # the messages to validate
16
-
17
- let(:example) { raise '`example` missing: add `let(:example) { example_name }` to your spec' }
18
- let(:messages) { raise '`messages` missing: add `let(:messages) { ndjson }` to your spec' }
19
-
20
- let(:example_path) { Cucumber::CompatibilityKit.example_path(example) }
21
-
22
- let(:parsed_original) { parse_ndjson_file("#{example_path}/#{example}.feature.ndjson") }
23
- let(:parsed_generated) { parse_ndjson(messages) }
24
-
25
- let(:original_messages_types) { parsed_original.map { |msg| message_type(msg) } }
26
- let(:generated_messages_types) { parsed_generated.map { |msg| message_type(msg) } }
27
-
28
- it 'generates valid message types' do
29
- expect(generated_messages_types).to contain_exactly(*original_messages_types)
30
- end
31
-
32
- it 'generates valid message structure' do
33
- comparator = CCK::MessagesComparator.new(parsed_generated, parsed_original)
34
-
35
- expect(comparator.errors).to be_empty, "There were comparison errors: #{comparator.errors}"
36
- end
37
-
38
- def parse_ndjson_file(path)
39
- parse_ndjson(File.read(path))
40
- end
41
-
42
- def parse_ndjson(ndjson)
43
- Cucumber::Messages::NdjsonToMessageEnumerator.new(ndjson)
44
- end
45
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec'
4
- require 'cucumber/messages'
5
- require_relative '../../lib/keys_checker'
6
-
7
- describe CCK::KeysChecker do
8
- describe '#compare' do
9
- let(:expected_values) { Cucumber::Messages::Attachment.new(url: 'https://foo.com', file_name: 'file.extension') }
10
- let(:erroneous_values) { Cucumber::Messages::Attachment.new(source: '1', test_step_id: '123') }
11
- let(:wrong_values) { Cucumber::Messages::Attachment.new(url: 'https://otherfoo.com', file_name: 'file.other') }
12
-
13
- it 'finds missing keys' do
14
- expect(described_class.compare(erroneous_values, expected_values)).to include(
15
- 'Missing keys in message Cucumber::Messages::Attachment: [:file_name, :url]'
16
- )
17
- end
18
-
19
- it 'finds extra keys' do
20
- expect(described_class.compare(erroneous_values, expected_values)).to include(
21
- 'Detected extra keys in message Cucumber::Messages::Attachment: [:source, :test_step_id]'
22
- )
23
- end
24
-
25
- it 'finds extra and missing keys' do
26
- expect(described_class.compare(erroneous_values, expected_values)).to contain_exactly(
27
- 'Missing keys in message Cucumber::Messages::Attachment: [:file_name, :url]',
28
- 'Detected extra keys in message Cucumber::Messages::Attachment: [:source, :test_step_id]'
29
- )
30
- end
31
-
32
- it 'does not care about the values' do
33
- expect(described_class.compare(expected_values, wrong_values)).to be_empty
34
- end
35
-
36
- context 'when default values are omitted' do
37
- let(:default_set) { Cucumber::Messages::Duration.new(seconds: 0, nanos: 12) }
38
- let(:default_not_set) { Cucumber::Messages::Duration.new(nanos: 12) }
39
-
40
- it 'does not raise an exception' do
41
- expect(described_class.compare(default_set, default_not_set)).to be_empty
42
- end
43
- end
44
-
45
- context 'when executed as part of a CI' do
46
- before { allow(ENV).to receive(:[]).with('CI').and_return(true) }
47
-
48
- it 'ignores actual CI related messages' do
49
- detected = Cucumber::Messages::Meta.new(ci: Cucumber::Messages::Ci.new(name: 'Some CI'))
50
- expected = Cucumber::Messages::Meta.new
51
-
52
- expect(described_class.compare(detected, expected)).to be_empty
53
- end
54
- end
55
-
56
- context 'when an unexpected error occurs' do
57
- it 'does not raise error' do
58
- expect { described_class.compare(nil, nil) }.not_to raise_error
59
- end
60
-
61
- it 'returns the error' do
62
- expect(described_class.compare(nil, nil))
63
- .to eq(['Unexpected error: wrong number of arguments (given 1, expected 0)'])
64
- end
65
- end
66
- end
67
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec'
4
- require 'cucumber/messages'
5
- require_relative '../../lib/messages_comparator'
6
-
7
- describe CCK::MessagesComparator do
8
- context 'when executed as part of a CI' do
9
- before { allow(ENV).to receive(:[]).with('CI').and_return(true) }
10
-
11
- let(:ci_message) { Cucumber::Messages::Ci.new(name: 'Some CI') }
12
- let(:blank_meta_message) { Cucumber::Messages::Meta.new }
13
- let(:filled_meta_message) { Cucumber::Messages::Meta.new(ci: ci_message) }
14
- let(:ci_message_envelope) { Cucumber::Messages::Envelope.new(meta: filled_meta_message) }
15
- let(:meta_message_envelope) { Cucumber::Messages::Envelope.new(meta: blank_meta_message) }
16
-
17
- it 'ignores any detected CI messages' do
18
- comparator = described_class.new([ci_message_envelope], [meta_message_envelope])
19
-
20
- expect(comparator.errors).to be_empty
21
- end
22
-
23
- it 'ignores any expected CI messages' do
24
- comparator = described_class.new([meta_message_envelope], [ci_message_envelope])
25
-
26
- expect(comparator.errors).to be_empty
27
- end
28
- end
29
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'cucumber-compatibility-kit'
4
-
5
- describe Cucumber::CompatibilityKit do
6
- let(:features_path) { File.expand_path("#{File.dirname(__FILE__)}/../../features") }
7
- let(:gherkin_examples) do
8
- %w[
9
- attachments
10
- cdata
11
- data-tables
12
- examples-tables
13
- hooks
14
- minimal
15
- parameter-types
16
- pending
17
- retry
18
- rules
19
- skipped
20
- stack-traces
21
- undefined
22
- unknown-parameter-type
23
- ]
24
- end
25
- let(:markdown_examples) { ['markdown'] }
26
-
27
- describe '#examples_path' do
28
- it 'returns the path of the features folder' do
29
- expect(described_class.examples_path).to eq(features_path)
30
- end
31
- end
32
-
33
- describe '#example_path' do
34
- context 'with an existing example' do
35
- it 'returns the path of the folder of the example' do
36
- expect(described_class.example_path('hooks')).to eq("#{features_path}/hooks")
37
- end
38
- end
39
-
40
- context 'with an non-existent example' do
41
- it 'raises ArgumentError' do
42
- expect { described_class.example_path('should-not-exists') }.to raise_error(ArgumentError)
43
- end
44
- end
45
- end
46
-
47
- describe '#gherkin_examples' do
48
- it 'returns the list of gherkin examples' do
49
- expect(described_class.gherkin_examples).to match_array(gherkin_examples)
50
- end
51
- end
52
-
53
- describe '#markdown_examples' do
54
- it 'returns the list of markdown examples' do
55
- expect(described_class.markdown_examples).to match_array(markdown_examples)
56
- end
57
- end
58
-
59
- describe '#all_examples' do
60
- it 'returns the list of all available examples' do
61
- expect(described_class.all_examples)
62
- .to match_array(gherkin_examples + markdown_examples)
63
- end
64
- end
65
- end