cucumber-core 3.2.1 → 4.0.0

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 (33) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +52 -0
  3. data/lib/cucumber/core/compiler.rb +37 -145
  4. data/lib/cucumber/core/events.rb +1 -4
  5. data/lib/cucumber/core/gherkin/parser.rb +14 -22
  6. data/lib/cucumber/core/report/summary.rb +1 -23
  7. data/lib/cucumber/core/test/action.rb +2 -2
  8. data/lib/cucumber/core/test/around_hook.rb +4 -0
  9. data/lib/cucumber/core/test/case.rb +15 -121
  10. data/lib/cucumber/core/{ast → test}/data_table.rb +6 -8
  11. data/lib/cucumber/core/{ast → test}/doc_string.rb +5 -9
  12. data/lib/cucumber/core/{ast → test}/empty_multiline_argument.rb +1 -2
  13. data/lib/cucumber/core/test/filters/locations_filter.rb +2 -2
  14. data/lib/cucumber/core/{ast → test}/location.rb +10 -17
  15. data/lib/cucumber/core/test/runner.rb +5 -3
  16. data/lib/cucumber/core/test/step.rb +20 -36
  17. data/lib/cucumber/core/{ast → test}/tag.rb +1 -1
  18. data/lib/cucumber/core/version.rb +1 -1
  19. metadata +12 -26
  20. data/lib/cucumber/core/ast.rb +0 -14
  21. data/lib/cucumber/core/ast/background.rb +0 -41
  22. data/lib/cucumber/core/ast/comment.rb +0 -28
  23. data/lib/cucumber/core/ast/describes_itself.rb +0 -21
  24. data/lib/cucumber/core/ast/empty_background.rb +0 -17
  25. data/lib/cucumber/core/ast/examples_table.rb +0 -119
  26. data/lib/cucumber/core/ast/feature.rb +0 -88
  27. data/lib/cucumber/core/ast/names.rb +0 -25
  28. data/lib/cucumber/core/ast/outline_step.rb +0 -53
  29. data/lib/cucumber/core/ast/scenario.rb +0 -42
  30. data/lib/cucumber/core/ast/scenario_outline.rb +0 -45
  31. data/lib/cucumber/core/ast/step.rb +0 -83
  32. data/lib/cucumber/core/gherkin/ast_builder.rb +0 -403
  33. data/lib/cucumber/core/gherkin/tag_expression.rb +0 -65
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
- require 'cucumber/core/ast/describes_itself'
3
- require 'cucumber/core/ast/location'
2
+ require 'cucumber/core/test/location'
4
3
 
5
4
  module Cucumber
6
5
  module Core
7
- module Ast
6
+ module Test
8
7
  # Step Definitions that match a plain text Step with a multiline argument table
9
8
  # will receive it as an instance of DataTable. A DataTable object holds the data of a
10
9
  # table parsed from a feature file and lets you access and manipulate the data
@@ -25,7 +24,6 @@ module Cucumber
25
24
  # This will store <tt>[['a', 'b'], ['c', 'd']]</tt> in the <tt>data</tt> variable.
26
25
  #
27
26
  class DataTable
28
- include DescribesItself
29
27
  include HasLocation
30
28
 
31
29
  # Creates a new instance. +raw+ should be an Array of Array of String
@@ -41,6 +39,10 @@ module Cucumber
41
39
  end
42
40
  attr_reader :raw
43
41
 
42
+ def describe_to(visitor, *args)
43
+ visitor.data_table(self, *args)
44
+ end
45
+
44
46
  def to_step_definition_arg
45
47
  dup
46
48
  end
@@ -109,10 +111,6 @@ module Cucumber
109
111
  [header] + hashes.map{|hash| header.map{|key| hash[key]}}
110
112
  end
111
113
 
112
- def description_for_visitors
113
- :data_table
114
- end
115
-
116
114
  end
117
115
  end
118
116
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
- require 'cucumber/core/ast/describes_itself'
3
2
  require 'delegate'
4
3
  module Cucumber
5
4
  module Core
6
- module Ast
5
+ module Test
7
6
  # Represents an inline argument in a step. Example:
8
7
  #
9
8
  # Given the message
@@ -22,7 +21,6 @@ module Cucumber
22
21
  #
23
22
  class DocString < SimpleDelegator
24
23
  include HasLocation
25
- include DescribesItself
26
24
 
27
25
  attr_reader :content_type, :content
28
26
 
@@ -33,6 +31,10 @@ module Cucumber
33
31
  super @content
34
32
  end
35
33
 
34
+ def describe_to(visitor, *args)
35
+ visitor.doc_string(self, *args)
36
+ end
37
+
36
38
  def data_table?
37
39
  false
38
40
  end
@@ -70,12 +72,6 @@ module Cucumber
70
72
  ].join("\n")
71
73
  end
72
74
 
73
- private
74
-
75
- def description_for_visitors
76
- :doc_string
77
- end
78
-
79
75
  end
80
76
  end
81
77
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Cucumber
3
3
  module Core
4
- module Ast
4
+ module Test
5
5
  class EmptyMultilineArgument
6
6
  def describe_to(*)
7
7
  self
@@ -30,4 +30,3 @@ module Cucumber
30
30
  end
31
31
  end
32
32
  end
33
-
@@ -25,8 +25,8 @@ module Cucumber
25
25
 
26
26
  def sorted_test_cases
27
27
  filter_locations.map { |filter_location|
28
- test_cases[filter_location.file].select { |test_case|
29
- test_case.all_locations.any? { |location| filter_location.match?(location) }
28
+ test_cases[filter_location.file].select { |test_case|
29
+ filter_location.match?(test_case.location)
30
30
  }
31
31
  }.flatten.uniq
32
32
  end
@@ -3,7 +3,7 @@ require 'forwardable'
3
3
  require 'cucumber/core/platform'
4
4
  module Cucumber
5
5
  module Core
6
- module Ast
6
+ module Test
7
7
  IncompatibleLocations = Class.new(StandardError)
8
8
 
9
9
  module Location
@@ -38,12 +38,6 @@ module Cucumber
38
38
  end
39
39
  end
40
40
 
41
- def self.merge(*locations)
42
- locations.reduce do |a, b|
43
- a + b
44
- end
45
- end
46
-
47
41
  class Wildcard < Struct.new(:file)
48
42
  def to_s
49
43
  file
@@ -88,11 +82,6 @@ module Cucumber
88
82
  Location.new(file, new_line)
89
83
  end
90
84
 
91
- def +(other)
92
- raise IncompatibleLocations if file != other.file
93
- Precise.new(file, lines + other.lines)
94
- end
95
-
96
85
  def inspect
97
86
  "<#{self.class}: #{to_s}>"
98
87
  end
@@ -110,6 +99,14 @@ module Cucumber
110
99
  data.first
111
100
  end
112
101
 
102
+ def min
103
+ data.min
104
+ end
105
+
106
+ def max
107
+ data.max
108
+ end
109
+
113
110
  def include?(other)
114
111
  other.data.subset?(data) || data.subset?(other.data)
115
112
  end
@@ -155,10 +152,6 @@ module Cucumber
155
152
  @location
156
153
  end
157
154
 
158
- def all_locations
159
- @all_locations ||= Location.merge([location] + attributes.map { |node| node.all_locations }.flatten)
160
- end
161
-
162
155
  def attributes
163
156
  [tags, comments, multiline_arg].flatten
164
157
  end
@@ -175,7 +168,7 @@ module Cucumber
175
168
 
176
169
  def multiline_arg
177
170
  # will be overriden by nodes that actually have a multiline_argument
178
- EmptyMultilineArgument.new
171
+ Test::EmptyMultilineArgument.new
179
172
  end
180
173
 
181
174
  end
@@ -17,7 +17,9 @@ module Cucumber
17
17
  @running_test_step = nil
18
18
  event_bus.test_case_started(test_case)
19
19
  descend.call(self)
20
- event_bus.test_case_finished(test_case, running_test_case.result)
20
+ result = running_test_case.result
21
+ result = Result::Undefined.new('The test case has no steps', Result::UnknownDuration.new, ["#{test_case.location}:in `#{test_case.name}'"]) if result.unknown?
22
+ event_bus.test_case_finished(test_case, result)
21
23
  self
22
24
  end
23
25
 
@@ -103,7 +105,7 @@ module Cucumber
103
105
  def execute(test_step, monitor, &continue)
104
106
  result = test_step.execute(monitor.result, &continue)
105
107
  result = result.with_message(%(Undefined step: "#{test_step.text}")) if result.undefined?
106
- result = result.with_appended_backtrace(test_step.source.last) if IsStepVisitor.new(test_step).step?
108
+ result = result.with_appended_backtrace(test_step) unless test_step.hook?
107
109
  result.describe_to(monitor, result)
108
110
  end
109
111
 
@@ -129,7 +131,7 @@ module Cucumber
129
131
  result = test_step.skip(monitor.result)
130
132
  if result.undefined?
131
133
  result = result.with_message(%(Undefined step: "#{test_step.text}"))
132
- result = result.with_appended_backtrace(test_step.source.last)
134
+ result = result.with_appended_backtrace(test_step)
133
135
  end
134
136
  result
135
137
  end
@@ -1,27 +1,29 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'cucumber/core/test/result'
3
4
  require 'cucumber/core/test/action'
5
+ require 'cucumber/core/test/empty_multiline_argument'
4
6
 
5
7
  module Cucumber
6
8
  module Core
7
9
  module Test
8
10
  class Step
9
- attr_reader :source
11
+ attr_reader :text, :location, :multiline_arg
10
12
 
11
- def initialize(source, action = Test::UndefinedAction.new(source.last.location))
12
- raise ArgumentError if source.any?(&:nil?)
13
- @source, @action = source, action
13
+ def initialize(text, location, multiline_arg = Test::EmptyMultilineArgument.new, action = Test::UndefinedAction.new(location))
14
+ raise ArgumentError if text.nil? || text.empty?
15
+ @text = text
16
+ @location = location
17
+ @multiline_arg = multiline_arg
18
+ @action = action
14
19
  end
15
20
 
16
21
  def describe_to(visitor, *args)
17
22
  visitor.test_step(self, *args)
18
23
  end
19
24
 
20
- def describe_source_to(visitor, *args)
21
- source.reverse.each do |node|
22
- node.describe_to(visitor, *args)
23
- end
24
- self
25
+ def hook?
26
+ false
25
27
  end
26
28
 
27
29
  def skip(*args)
@@ -32,26 +34,18 @@ module Cucumber
32
34
  @action.execute(*args)
33
35
  end
34
36
 
35
- def with_action(location = nil, &block)
36
- self.class.new(source, Test::Action.new(location, &block))
37
+ def with_action(action_location = nil, &block)
38
+ self.class.new(text, location, multiline_arg, Test::Action.new(action_location, &block))
37
39
  end
38
40
 
39
- def text
40
- source.last.text
41
+ def backtrace_line
42
+ "#{location}:in `#{text}'"
41
43
  end
42
44
 
43
45
  def to_s
44
46
  text
45
47
  end
46
48
 
47
- def location
48
- source.last.location
49
- end
50
-
51
- def original_location
52
- source.last.original_location
53
- end
54
-
55
49
  def action_location
56
50
  @action.location
57
51
  end
@@ -59,25 +53,15 @@ module Cucumber
59
53
  def inspect
60
54
  "#<#{self.class}: #{location}>"
61
55
  end
62
-
63
56
  end
64
57
 
65
- class IsStepVisitor
66
- def initialize(test_step)
67
- @is_step = false
68
- test_step.describe_to(self)
69
- end
70
-
71
- def step?
72
- @is_step
73
- end
74
-
75
- def test_step(*)
76
- @is_step = true
58
+ class HookStep < Step
59
+ def initialize(text, location, action)
60
+ super(text, location, Test::EmptyMultilineArgument.new, action)
77
61
  end
78
62
 
79
- def method_missing(*)
80
- self
63
+ def hook?
64
+ true
81
65
  end
82
66
  end
83
67
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Cucumber
3
3
  module Core
4
- module Ast
4
+ module Test
5
5
  class Tag
6
6
  include HasLocation
7
7
 
@@ -3,7 +3,7 @@ module Cucumber
3
3
  module Core
4
4
  class Version
5
5
  def self.to_s
6
- "3.2.1"
6
+ "4.0.0"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-09-24 00:00:00.000000000 Z
15
+ date: 2018-09-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: gherkin
@@ -20,14 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - "~>"
22
22
  - !ruby/object:Gem::Version
23
- version: '5.0'
23
+ version: '6.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - "~>"
29
29
  - !ruby/object:Gem::Version
30
- version: '5.0'
30
+ version: '6.0'
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: cucumber-tag_expressions
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -165,32 +165,13 @@ files:
165
165
  - LICENSE
166
166
  - README.md
167
167
  - lib/cucumber/core.rb
168
- - lib/cucumber/core/ast.rb
169
- - lib/cucumber/core/ast/background.rb
170
- - lib/cucumber/core/ast/comment.rb
171
- - lib/cucumber/core/ast/data_table.rb
172
- - lib/cucumber/core/ast/describes_itself.rb
173
- - lib/cucumber/core/ast/doc_string.rb
174
- - lib/cucumber/core/ast/empty_background.rb
175
- - lib/cucumber/core/ast/empty_multiline_argument.rb
176
- - lib/cucumber/core/ast/examples_table.rb
177
- - lib/cucumber/core/ast/feature.rb
178
- - lib/cucumber/core/ast/location.rb
179
- - lib/cucumber/core/ast/names.rb
180
- - lib/cucumber/core/ast/outline_step.rb
181
- - lib/cucumber/core/ast/scenario.rb
182
- - lib/cucumber/core/ast/scenario_outline.rb
183
- - lib/cucumber/core/ast/step.rb
184
- - lib/cucumber/core/ast/tag.rb
185
168
  - lib/cucumber/core/compiler.rb
186
169
  - lib/cucumber/core/event.rb
187
170
  - lib/cucumber/core/event_bus.rb
188
171
  - lib/cucumber/core/events.rb
189
172
  - lib/cucumber/core/filter.rb
190
- - lib/cucumber/core/gherkin/ast_builder.rb
191
173
  - lib/cucumber/core/gherkin/document.rb
192
174
  - lib/cucumber/core/gherkin/parser.rb
193
- - lib/cucumber/core/gherkin/tag_expression.rb
194
175
  - lib/cucumber/core/gherkin/writer.rb
195
176
  - lib/cucumber/core/gherkin/writer/helpers.rb
196
177
  - lib/cucumber/core/platform.rb
@@ -198,14 +179,19 @@ files:
198
179
  - lib/cucumber/core/test/action.rb
199
180
  - lib/cucumber/core/test/around_hook.rb
200
181
  - lib/cucumber/core/test/case.rb
182
+ - lib/cucumber/core/test/data_table.rb
183
+ - lib/cucumber/core/test/doc_string.rb
184
+ - lib/cucumber/core/test/empty_multiline_argument.rb
201
185
  - lib/cucumber/core/test/filters.rb
202
186
  - lib/cucumber/core/test/filters/activate_steps_for_self_test.rb
203
187
  - lib/cucumber/core/test/filters/locations_filter.rb
204
188
  - lib/cucumber/core/test/filters/name_filter.rb
205
189
  - lib/cucumber/core/test/filters/tag_filter.rb
190
+ - lib/cucumber/core/test/location.rb
206
191
  - lib/cucumber/core/test/result.rb
207
192
  - lib/cucumber/core/test/runner.rb
208
193
  - lib/cucumber/core/test/step.rb
194
+ - lib/cucumber/core/test/tag.rb
209
195
  - lib/cucumber/core/test/timer.rb
210
196
  - lib/cucumber/core/version.rb
211
197
  homepage: https://cucumber.io
@@ -221,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
207
  requirements:
222
208
  - - ">="
223
209
  - !ruby/object:Gem::Version
224
- version: '2.1'
210
+ version: '2.2'
225
211
  required_rubygems_version: !ruby/object:Gem::Requirement
226
212
  requirements:
227
213
  - - ">="
@@ -229,8 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
215
  version: '0'
230
216
  requirements: []
231
217
  rubyforge_project:
232
- rubygems_version: 2.4.5.4
218
+ rubygems_version: 2.7.4
233
219
  signing_key:
234
220
  specification_version: 4
235
- summary: cucumber-core-3.2.1
221
+ summary: cucumber-core-4.0.0
236
222
  test_files: []
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/ast/comment'
3
- require 'cucumber/core/ast/tag'
4
- require 'cucumber/core/ast/feature'
5
- require 'cucumber/core/ast/empty_background'
6
- require 'cucumber/core/ast/empty_multiline_argument'
7
- require 'cucumber/core/ast/background'
8
- require 'cucumber/core/ast/scenario'
9
- require 'cucumber/core/ast/step'
10
- require 'cucumber/core/ast/doc_string'
11
- require 'cucumber/core/ast/data_table'
12
- require 'cucumber/core/ast/scenario_outline'
13
- require 'cucumber/core/ast/outline_step'
14
- require 'cucumber/core/ast/examples_table'
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'cucumber/core/ast/names'
3
- require 'cucumber/core/ast/location'
4
- require 'cucumber/core/ast/describes_itself'
5
-
6
- module Cucumber
7
- module Core
8
- module Ast
9
- class Background
10
- include Names
11
- include HasLocation
12
- include DescribesItself
13
-
14
- def initialize(location, comments, keyword, name, description, raw_steps)
15
- @location = location
16
- @comments = comments
17
- @keyword = keyword
18
- @name = name
19
- @description = description
20
- @raw_steps = raw_steps
21
- end
22
-
23
- attr_reader :description, :raw_steps
24
- private :raw_steps
25
-
26
- attr_reader :comments, :keyword, :location
27
-
28
- def children
29
- raw_steps
30
- end
31
-
32
- private
33
-
34
- def description_for_visitors
35
- :background
36
- end
37
-
38
- end
39
- end
40
- end
41
- end