cucumber-core 15.4.0 → 16.1.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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/lib/cucumber/core/event.rb +2 -3
  4. data/lib/cucumber/core/event_bus.rb +2 -2
  5. data/lib/cucumber/core/events/envelope.rb +13 -0
  6. data/lib/cucumber/core/events/gherkin_source_parsed.rb +15 -0
  7. data/lib/cucumber/core/events/test_case_created.rb +18 -0
  8. data/lib/cucumber/core/events/test_case_finished.rb +18 -0
  9. data/lib/cucumber/core/events/test_case_started.rb +15 -0
  10. data/lib/cucumber/core/events/test_step_created.rb +18 -0
  11. data/lib/cucumber/core/events/test_step_finished.rb +18 -0
  12. data/lib/cucumber/core/events/test_step_started.rb +15 -0
  13. data/lib/cucumber/core/events.rb +14 -69
  14. data/lib/cucumber/core/gherkin/writer/background.rb +33 -0
  15. data/lib/cucumber/core/gherkin/writer/doc_string.rb +41 -0
  16. data/lib/cucumber/core/gherkin/writer/example.rb +18 -0
  17. data/lib/cucumber/core/gherkin/writer/examples.rb +39 -0
  18. data/lib/cucumber/core/gherkin/writer/feature.rb +49 -0
  19. data/lib/cucumber/core/gherkin/writer/gherkin.rb +39 -0
  20. data/lib/cucumber/core/gherkin/writer/rule.rb +35 -0
  21. data/lib/cucumber/core/gherkin/writer/scenario.rb +33 -0
  22. data/lib/cucumber/core/gherkin/writer/scenario_outline.rb +28 -0
  23. data/lib/cucumber/core/gherkin/writer/step.rb +37 -0
  24. data/lib/cucumber/core/gherkin/writer/table.rb +28 -0
  25. data/lib/cucumber/core/gherkin/writer.rb +17 -256
  26. data/lib/cucumber/core/test/action/defined.rb +2 -2
  27. data/lib/cucumber/core/test/action/unskippable.rb +2 -2
  28. data/lib/cucumber/core/test/around_hook.rb +2 -2
  29. data/lib/cucumber/core/test/data_table.rb +2 -2
  30. data/lib/cucumber/core/test/doc_string.rb +3 -3
  31. data/lib/cucumber/core/test/result.rb +22 -24
  32. data/lib/cucumber/core/test/runner.rb +6 -6
  33. data/lib/cucumber/core/test/step.rb +8 -8
  34. metadata +33 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d6c44db30c6049a00aaa02f36c1a5bd85471d617703ba794808a8073afb5266
4
- data.tar.gz: 0ed650cf7aca55c6716f1977e9bdfec144d59d6a0634de0e0616fe1ca58f8cd5
3
+ metadata.gz: 1710a14ed278897b31a075938c655efc6614d353ec7ca37102f43460bc454934
4
+ data.tar.gz: bd2fd69c1ddef3e4d41bcc3145495a3eb43b3e19645a3daf6f134debcc5e73e0
5
5
  SHA512:
6
- metadata.gz: 3967dc02fdb31308428fefd9acb4014795bcdb102c675a40b5a7498592c674faee4ee77f178aaf5c78241f73c8c62828b3348e09b9b7d39ada08758cfd6c1361
7
- data.tar.gz: 91d51f70480b132d549b8bc8229a29e24b169052461422f4198b4a79ce3652ef6ce2f4226822c2d5ce6a8a85d46cf2ca8b63dcd0cc965ecff084a8fcd5235c49
6
+ metadata.gz: 6c59caed7891d014027f2d83511961cf768066a66f7f033a05dd1f868cb88fc843c276c3645ecf5af5ac020e048a62c3966277672bc3a356ba1f3ea94d0e76c9
7
+ data.tar.gz: 13a00c9ea789204fb36f2a45a71df9073e53f36953e1ef3640cd30c45baae405da85ff583f1d8d77edca34ffd97895bbd1b845cd7a345b7582cc817e2b85c7d6
data/CHANGELOG.md CHANGED
@@ -10,6 +10,22 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [16.1.1] - 2025-12-24
14
+ ### Fixed
15
+ - Added a fix that prevented the `Duration` class from not being able to calculate duration correctly
16
+
17
+ ## [16.1.0] - 2025-12-22
18
+ ### Changed
19
+ - Code re-organised into more sub-files. No user facing changes
20
+ - Further bumped the lower bounds of messages and gherkin several more versions
21
+
22
+ ## [16.0.0] - 2025-12-16
23
+ ### Changed
24
+ - Bumped the lower bounds of messages to v28, gherkin to v33 and tag-expressions to v6
25
+
26
+ ### Removed
27
+ - Remove support for ruby 3.1 and below. 3.2 or higher is required now
28
+
13
29
  ## [15.4.0] - 2025-12-10
14
30
  ### Changed
15
31
  - Permit usage of gherkin up to v39, messages up to v32
@@ -111,7 +127,10 @@ See upgrading notes for [13.0.0.md](upgrading_notes/13.0.0.md#upgrading-to-cucum
111
127
  ### Changed
112
128
  - Updated `cucumber-gherkin` and `cucumber-messages`
113
129
 
114
- [Unreleased]: https://github.com/cucumber/cucumber-ruby-core/compare/v15.4.0...HEAD
130
+ [Unreleased]: https://github.com/cucumber/cucumber-ruby-core/compare/v16.1.1...HEAD
131
+ [16.1.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v16.1.0...v16.1.1
132
+ [16.1.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v16.0.0...v16.1.0
133
+ [16.0.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v15.4.0...v16.0.0
115
134
  [15.4.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v15.3.0...v15.4.0
116
135
  [15.3.0]: https://github.com/cucumber/cucumber-ruby-core/compare/v15.2.1...v15.3.0
117
136
  [15.2.1]: https://github.com/cucumber/cucumber-ruby-core/compare/v15.2.0...v15.2.1
@@ -3,11 +3,10 @@
3
3
  module Cucumber
4
4
  module Core
5
5
  class Event
6
- # Macro to generate new sub-classes of {Event} with
7
- # attribute readers.
6
+ # Macro to generate new subclasses of {Event} with attribute readers.
8
7
  def self.new(*events)
9
8
  # Use normal constructor for subclasses of Event
10
- return super if ancestors.index(Event) > 0
9
+ return super if ancestors.index(Event).positive?
11
10
 
12
11
  Class.new(Event) do
13
12
  # NB: We need to use metaprogramming here instead of direct variable obtainment
@@ -34,9 +34,9 @@ module Cucumber
34
34
  @event_queue << event
35
35
  end
36
36
 
37
- def method_missing(event_id, *args)
37
+ def method_missing(event_id, *)
38
38
  event_class = event_types.fetch(event_id) { super }
39
- broadcast event_class.new(*args)
39
+ broadcast event_class.new(*)
40
40
  end
41
41
 
42
42
  def respond_to_missing?(event_id, *args)
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ class Envelope < Event.new(:envelope)
9
+ attr_reader :envelope
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ # Signals that a gherkin source has been parsed
9
+ class GherkinSourceParsed < Event.new(:gherkin_document)
10
+ # @return [GherkinDocument] the GherkinDocument Ast Node
11
+ attr_reader :gherkin_document
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ # Signals that a Test::Case was created from a Pickle
9
+ class TestCaseCreated < Event.new(:test_case, :pickle)
10
+ # The created test step
11
+ attr_reader :test_case
12
+
13
+ # The source pickle step
14
+ attr_reader :pickle
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ # Signals that a {Test::Case} has finished executing
9
+ class TestCaseFinished < Event.new(:test_case, :result)
10
+ # @return [Test::Case] that was executed
11
+ attr_reader :test_case
12
+
13
+ # @return [Test::Result] the result of running the {Test::Step}
14
+ attr_reader :result
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ # Signals that a {Test::Case} is about to be executed
9
+ class TestCaseStarted < Event.new(:test_case)
10
+ # @return [Test::Case] the test case to be executed
11
+ attr_reader :test_case
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ # Signals that a Test::Step was created from a PickleStep
9
+ class TestStepCreated < Event.new(:test_step, :pickle_step)
10
+ # The created test step
11
+ attr_reader :test_step
12
+
13
+ # The source pickle step
14
+ attr_reader :pickle_step
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ # Signals that a {Test::Step} has finished executing
9
+ class TestStepFinished < Event.new(:test_step, :result)
10
+ # @return [Test::Step] the test step that was executed
11
+ attr_reader :test_step
12
+
13
+ # @return [Test::Result] the result of running the {Test::Step}
14
+ attr_reader :result
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../event'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Events
8
+ # Signals that a {Test::Step} is about to be executed
9
+ class TestStepStarted < Event.new(:test_step)
10
+ # @return [Test::Step] the test step to be executed
11
+ attr_reader :test_step
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,88 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'cucumber/core/event'
3
+ require_relative 'events/envelope'
4
+ require_relative 'events/gherkin_source_parsed'
5
+ require_relative 'events/test_case_created'
6
+ require_relative 'events/test_case_started'
7
+ require_relative 'events/test_case_finished'
8
+ require_relative 'events/test_step_created'
9
+ require_relative 'events/test_step_started'
10
+ require_relative 'events/test_step_finished'
4
11
 
5
12
  module Cucumber
6
13
  module Core
7
14
  module Events
8
- class Envelope < Event.new(:envelope)
9
- attr_reader :envelope
10
- end
11
-
12
- # Signals that a gherkin source has been parsed
13
- class GherkinSourceParsed < Event.new(:gherkin_document)
14
- # @return [GherkinDocument] the GherkinDocument Ast Node
15
- attr_reader :gherkin_document
16
- end
17
-
18
- # Signals that a Test::Step was created from a PickleStep
19
- class TestStepCreated < Event.new(:test_step, :pickle_step)
20
- # The created test step
21
- attr_reader :test_step
22
-
23
- # The source pickle step
24
- attr_reader :pickle_step
25
- end
26
-
27
- # Signals that a Test::Case was created from a Pickle
28
- class TestCaseCreated < Event.new(:test_case, :pickle)
29
- # The created test step
30
- attr_reader :test_case
31
-
32
- # The source pickle step
33
- attr_reader :pickle
34
- end
35
-
36
- # Signals that a {Test::Case} is about to be executed
37
- class TestCaseStarted < Event.new(:test_case)
38
- # @return [Test::Case] the test case to be executed
39
- attr_reader :test_case
40
- end
41
-
42
- # Signals that a {Test::Step} is about to be executed
43
- class TestStepStarted < Event.new(:test_step)
44
- # @return [Test::Step] the test step to be executed
45
- attr_reader :test_step
46
- end
47
-
48
- # Signals that a {Test::Step} has finished executing
49
- class TestStepFinished < Event.new(:test_step, :result)
50
- # @return [Test::Step] the test step that was executed
51
- attr_reader :test_step
52
-
53
- # @return [Test::Result] the result of running the {Test::Step}
54
- attr_reader :result
55
- end
56
-
57
- # Signals that a {Test::Case} has finished executing
58
- class TestCaseFinished < Event.new(:test_case, :result)
59
- # @return [Test::Case] that was executed
60
- attr_reader :test_case
61
-
62
- # @return [Test::Result] the result of running the {Test::Step}
63
- attr_reader :result
64
- end
65
-
66
- # The registry contains all the events registered in the core,
67
- # that will be used by the {EventBus} by default.
15
+ # The registry contains all the events registered in the core, that will be used by the {EventBus} by default.
68
16
  def self.registry
69
17
  build_registry(
70
18
  Envelope,
71
19
  GherkinSourceParsed,
72
- TestStepCreated,
73
20
  TestCaseCreated,
74
21
  TestCaseStarted,
22
+ TestCaseFinished,
23
+ TestStepCreated,
75
24
  TestStepStarted,
76
- TestStepFinished,
77
- TestCaseFinished
25
+ TestStepFinished
78
26
  )
79
27
  end
80
28
 
81
- # Build an event registry to be passed to the {EventBus}
82
- # constructor from a list of types.
83
- #
84
- # Each type must respond to `event_id` so that it can be added
85
- # to the registry hash.
29
+ # Build an event registry to be passed to the {EventBus} constructor from a list of types.
30
+ # Each type must respond to `event_id` so that it can be added to the registry hash
86
31
  #
87
32
  # @return [Hash{Symbol => Class}]
88
33
  def self.build_registry(*types)
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Gherkin
8
+ module Writer
9
+ class Background
10
+ include HasElements
11
+ include HasOptionsInitializer
12
+ include HasDescription
13
+ include Indentation.level 2
14
+
15
+ default_keyword 'Background'
16
+
17
+ elements :step
18
+
19
+ private
20
+
21
+ def statements
22
+ prepare_statements(
23
+ comments_statement,
24
+ tag_statement,
25
+ name_statement,
26
+ description_statement
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Gherkin
8
+ module Writer
9
+ class DocString
10
+ include Indentation.level(6)
11
+
12
+ attr_reader :strings, :content_type
13
+ private :strings, :content_type
14
+
15
+ def initialize(string, content_type)
16
+ @strings = string.split("\n").map(&:strip)
17
+ @content_type = content_type
18
+ end
19
+
20
+ def build(source)
21
+ source + statements
22
+ end
23
+
24
+ private
25
+
26
+ def statements
27
+ prepare_statements doc_string_statement
28
+ end
29
+
30
+ def doc_string_statement
31
+ [
32
+ %("""#{content_type}),
33
+ strings,
34
+ '"""'
35
+ ]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+ require_relative 'scenario'
5
+
6
+ module Cucumber
7
+ module Core
8
+ module Gherkin
9
+ module Writer
10
+ class Example < Scenario
11
+ include Indentation.level 4
12
+
13
+ default_keyword 'Example'
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Gherkin
8
+ module Writer
9
+ class Examples
10
+ NEW_LINE = ''
11
+
12
+ include HasOptionsInitializer
13
+ include HasRows
14
+ include HasDescription
15
+ include Indentation.level(4)
16
+
17
+ default_keyword 'Examples'
18
+
19
+ def build(source)
20
+ source + statements
21
+ end
22
+
23
+ private
24
+
25
+ def statements
26
+ prepare_statements(
27
+ NEW_LINE,
28
+ comments_statement,
29
+ tag_statement,
30
+ name_statement,
31
+ description_statement,
32
+ row_statements(2)
33
+ )
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Gherkin
8
+ module Writer
9
+ class Feature
10
+ NEW_LINE = ''
11
+
12
+ include HasElements
13
+ include HasOptionsInitializer
14
+ include HasDescription
15
+ include Indentation.level(0)
16
+
17
+ default_keyword 'Feature'
18
+
19
+ elements :background, :rule, :scenario, :scenario_outline
20
+
21
+ def build(source = [])
22
+ elements.inject(source + statements) { |acc, el| el.build(acc) + [NEW_LINE] }
23
+ end
24
+
25
+ private
26
+
27
+ def language
28
+ options[:language]
29
+ end
30
+
31
+ def statements
32
+ prepare_statements(
33
+ language_statement,
34
+ comments_statement,
35
+ tag_statement,
36
+ name_statement,
37
+ description_statement,
38
+ NEW_LINE
39
+ )
40
+ end
41
+
42
+ def language_statement
43
+ "# language: #{language}" if language
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../document'
4
+ require_relative 'feature'
5
+
6
+ module Cucumber
7
+ module Core
8
+ module Gherkin
9
+ module Writer
10
+ class Gherkin
11
+ def initialize(uri, &source)
12
+ @uri = uri
13
+ @source = source
14
+ end
15
+
16
+ def comment(line)
17
+ comment_lines << "# #{line}"
18
+ end
19
+
20
+ def comment_lines
21
+ @comment_lines ||= []
22
+ end
23
+
24
+ def feature(*args, &source)
25
+ @feature = Feature.new(comment_lines, *args).tap do |builder|
26
+ builder.instance_exec(&source) if source
27
+ end
28
+ self
29
+ end
30
+
31
+ def build
32
+ instance_exec(&@source)
33
+ Document.new(@uri, @feature.build.join("\n"))
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Gherkin
8
+ module Writer
9
+ class Rule
10
+ NEW_LINE = ''
11
+
12
+ include HasElements
13
+ include HasOptionsInitializer
14
+ include HasDescription
15
+ include Indentation.level 2
16
+
17
+ default_keyword 'Rule'
18
+
19
+ elements :example, :scenario
20
+
21
+ private
22
+
23
+ def statements
24
+ prepare_statements(
25
+ comments_statement,
26
+ name_statement,
27
+ description_statement,
28
+ NEW_LINE
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Gherkin
8
+ module Writer
9
+ class Scenario
10
+ include HasElements
11
+ include HasOptionsInitializer
12
+ include HasDescription
13
+ include Indentation.level 2
14
+
15
+ default_keyword 'Scenario'
16
+
17
+ elements :step
18
+
19
+ private
20
+
21
+ def statements
22
+ prepare_statements(
23
+ comments_statement,
24
+ tag_statement,
25
+ name_statement,
26
+ description_statement
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ module Cucumber
6
+ module Core
7
+ module Gherkin
8
+ module Writer
9
+ class ScenarioOutline
10
+ include HasElements
11
+ include HasOptionsInitializer
12
+ include HasDescription
13
+ include Indentation.level 2
14
+
15
+ default_keyword 'Scenario Outline'
16
+
17
+ elements :step, :examples
18
+
19
+ private
20
+
21
+ def statements
22
+ prepare_statements comments_statement, tag_statement, name_statement, description_statement
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+
5
+ require_relative 'doc_string'
6
+
7
+ module Cucumber
8
+ module Core
9
+ module Gherkin
10
+ module Writer
11
+ class Step
12
+ include HasElements
13
+ include HasOptionsInitializer
14
+ include Indentation.level 4
15
+
16
+ default_keyword 'Given'
17
+
18
+ elements :table
19
+
20
+ def doc_string(string, content_type = '')
21
+ elements << DocString.new(string, content_type)
22
+ end
23
+
24
+ private
25
+
26
+ def statements
27
+ prepare_statements comments_statement, name_statement
28
+ end
29
+
30
+ def name_statement
31
+ "#{keyword} #{name}"
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end