cucumber-core 3.2.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +52 -0
- data/lib/cucumber/core/compiler.rb +37 -145
- data/lib/cucumber/core/events.rb +1 -4
- data/lib/cucumber/core/gherkin/parser.rb +14 -22
- data/lib/cucumber/core/report/summary.rb +1 -23
- data/lib/cucumber/core/test/action.rb +2 -2
- data/lib/cucumber/core/test/around_hook.rb +4 -0
- data/lib/cucumber/core/test/case.rb +15 -121
- data/lib/cucumber/core/{ast → test}/data_table.rb +6 -8
- data/lib/cucumber/core/{ast → test}/doc_string.rb +5 -9
- data/lib/cucumber/core/{ast → test}/empty_multiline_argument.rb +1 -2
- data/lib/cucumber/core/test/filters/locations_filter.rb +2 -2
- data/lib/cucumber/core/{ast → test}/location.rb +10 -17
- data/lib/cucumber/core/test/runner.rb +5 -3
- data/lib/cucumber/core/test/step.rb +20 -36
- data/lib/cucumber/core/{ast → test}/tag.rb +1 -1
- data/lib/cucumber/core/version.rb +1 -1
- metadata +12 -26
- data/lib/cucumber/core/ast.rb +0 -14
- data/lib/cucumber/core/ast/background.rb +0 -41
- data/lib/cucumber/core/ast/comment.rb +0 -28
- data/lib/cucumber/core/ast/describes_itself.rb +0 -21
- data/lib/cucumber/core/ast/empty_background.rb +0 -17
- data/lib/cucumber/core/ast/examples_table.rb +0 -119
- data/lib/cucumber/core/ast/feature.rb +0 -88
- data/lib/cucumber/core/ast/names.rb +0 -25
- data/lib/cucumber/core/ast/outline_step.rb +0 -53
- data/lib/cucumber/core/ast/scenario.rb +0 -42
- data/lib/cucumber/core/ast/scenario_outline.rb +0 -45
- data/lib/cucumber/core/ast/step.rb +0 -83
- data/lib/cucumber/core/gherkin/ast_builder.rb +0 -403
- data/lib/cucumber/core/gherkin/tag_expression.rb +0 -65
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/location'
|
3
|
-
|
4
|
-
module Cucumber
|
5
|
-
module Core
|
6
|
-
module Ast
|
7
|
-
class Comment
|
8
|
-
include HasLocation
|
9
|
-
|
10
|
-
attr_reader :location, :value
|
11
|
-
private :value
|
12
|
-
|
13
|
-
def initialize(location, value)
|
14
|
-
@location = location
|
15
|
-
@value = value
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
value
|
20
|
-
end
|
21
|
-
|
22
|
-
def inspect
|
23
|
-
%{#<#{self.class} #{value} (#{location})}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Cucumber
|
3
|
-
module Core
|
4
|
-
module Ast
|
5
|
-
module DescribesItself
|
6
|
-
def describe_to(visitor, *args)
|
7
|
-
visitor.send(description_for_visitors, self, *args) do |child_visitor|
|
8
|
-
children.each do |child|
|
9
|
-
begin
|
10
|
-
child.describe_to(child_visitor, *args)
|
11
|
-
rescue => e
|
12
|
-
raise e.class, "Failed describing child of #{self.inspect} - #{e.message}", e.backtrace
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
self
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/describes_itself'
|
3
|
-
require 'cucumber/core/ast/location'
|
4
|
-
require 'cucumber/core/ast/names'
|
5
|
-
|
6
|
-
module Cucumber
|
7
|
-
module Core
|
8
|
-
module Ast
|
9
|
-
|
10
|
-
class ExamplesTable
|
11
|
-
include Names
|
12
|
-
include HasLocation
|
13
|
-
include DescribesItself
|
14
|
-
|
15
|
-
def initialize(location, comments, tags, keyword, name, description, header, example_rows)
|
16
|
-
@location = location
|
17
|
-
@comments = comments
|
18
|
-
@tags = tags
|
19
|
-
@keyword = keyword
|
20
|
-
@name = name
|
21
|
-
@description = description
|
22
|
-
@header = header
|
23
|
-
@example_rows = example_rows
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_reader :location, :tags, :keyword, :comments,
|
27
|
-
:header, :example_rows
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def description_for_visitors
|
32
|
-
:examples_table
|
33
|
-
end
|
34
|
-
|
35
|
-
def children
|
36
|
-
@example_rows
|
37
|
-
end
|
38
|
-
|
39
|
-
class Header
|
40
|
-
include HasLocation
|
41
|
-
|
42
|
-
attr_reader :comments
|
43
|
-
|
44
|
-
def initialize(cells, location, comments)
|
45
|
-
@cells = cells
|
46
|
-
@location = location
|
47
|
-
@comments = comments
|
48
|
-
end
|
49
|
-
|
50
|
-
def values
|
51
|
-
@cells
|
52
|
-
end
|
53
|
-
|
54
|
-
def build_row(row_cells, number, location, language, comments)
|
55
|
-
Row.new(Hash[@cells.zip(row_cells)], number, location, language, comments)
|
56
|
-
end
|
57
|
-
|
58
|
-
def inspect
|
59
|
-
"#<#{self.class} #{values} (#{location})>"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class Row
|
64
|
-
include DescribesItself
|
65
|
-
include HasLocation
|
66
|
-
|
67
|
-
attr_reader :number, :language, :comments
|
68
|
-
|
69
|
-
def initialize(data, number, location, language, comments)
|
70
|
-
raise ArgumentError, data.to_s unless data.is_a?(Hash)
|
71
|
-
@data = data
|
72
|
-
@number = number
|
73
|
-
@location = location
|
74
|
-
@language = language
|
75
|
-
@comments = comments
|
76
|
-
end
|
77
|
-
|
78
|
-
def ==(other)
|
79
|
-
return false unless other.class == self.class
|
80
|
-
other.number == number &&
|
81
|
-
other.location == location &&
|
82
|
-
other.data == data
|
83
|
-
end
|
84
|
-
|
85
|
-
def [](parameter_name)
|
86
|
-
@data[parameter_name]
|
87
|
-
end
|
88
|
-
|
89
|
-
def values
|
90
|
-
@data.values
|
91
|
-
end
|
92
|
-
|
93
|
-
def expand(string)
|
94
|
-
result = string.dup
|
95
|
-
@data.each do |key, value|
|
96
|
-
result.gsub!("<#{key}>", value.to_s)
|
97
|
-
end
|
98
|
-
result
|
99
|
-
end
|
100
|
-
|
101
|
-
def inspect
|
102
|
-
"#<#{self.class}: #{@data.inspect} (#{location})>"
|
103
|
-
end
|
104
|
-
|
105
|
-
protected
|
106
|
-
|
107
|
-
attr_reader :data
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def description_for_visitors
|
112
|
-
:examples_table_row
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
class Examples < ExamplesTable; end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/describes_itself'
|
3
|
-
require 'cucumber/core/ast/names'
|
4
|
-
require 'cucumber/core/ast/location'
|
5
|
-
require 'gherkin/dialect'
|
6
|
-
|
7
|
-
module Cucumber
|
8
|
-
module Core
|
9
|
-
module Ast
|
10
|
-
# Represents the root node of a parsed feature.
|
11
|
-
class Feature
|
12
|
-
include Names
|
13
|
-
include HasLocation
|
14
|
-
include DescribesItself
|
15
|
-
|
16
|
-
attr_reader :language, :location, :background,
|
17
|
-
:comments, :tags, :keyword, :description,
|
18
|
-
:feature_elements
|
19
|
-
|
20
|
-
def initialize(language, location, comments, tags, keyword, name, description, feature_elements)
|
21
|
-
@language = language
|
22
|
-
@location = location
|
23
|
-
@background = BackgroundFinder.new(feature_elements).result
|
24
|
-
@comments = comments
|
25
|
-
@tags = tags
|
26
|
-
@keyword = keyword
|
27
|
-
@name = name
|
28
|
-
@description = description
|
29
|
-
@feature_elements = feature_elements
|
30
|
-
end
|
31
|
-
|
32
|
-
def children
|
33
|
-
@feature_elements
|
34
|
-
end
|
35
|
-
|
36
|
-
def short_name
|
37
|
-
first_line = name.split(/\n/)[0]
|
38
|
-
if first_line =~ /#{language.feature_keywords}:(.*)/
|
39
|
-
$1.strip
|
40
|
-
else
|
41
|
-
first_line
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def description_for_visitors
|
48
|
-
:feature
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
class NullFeature
|
54
|
-
def method_missing(*args, &block)
|
55
|
-
self
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class BackgroundFinder
|
60
|
-
def initialize(feature_elements)
|
61
|
-
@background = nil
|
62
|
-
feature_elements[0].describe_to(self) unless feature_elements.empty?
|
63
|
-
end
|
64
|
-
|
65
|
-
def background(background)
|
66
|
-
@background = background
|
67
|
-
end
|
68
|
-
|
69
|
-
def result
|
70
|
-
@background ? @background : EmptyBackground.new
|
71
|
-
end
|
72
|
-
|
73
|
-
def method_missing(*)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
require 'delegate'
|
78
|
-
class LanguageDelegator < SimpleDelegator
|
79
|
-
attr_reader :iso_code
|
80
|
-
|
81
|
-
def initialize(iso_code, obj)
|
82
|
-
super(obj)
|
83
|
-
@iso_code = iso_code
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Cucumber
|
3
|
-
module Core
|
4
|
-
module Ast
|
5
|
-
module Names
|
6
|
-
attr_reader :description, :name
|
7
|
-
|
8
|
-
def legacy_conflated_name_and_description
|
9
|
-
s = name
|
10
|
-
s += "\n#{@description}" if @description != ""
|
11
|
-
s
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_s
|
15
|
-
name
|
16
|
-
end
|
17
|
-
|
18
|
-
def inspect
|
19
|
-
keyword_and_name = [keyword, name].join(": ")
|
20
|
-
%{#<#{self.class} "#{keyword_and_name}" (#{location})>}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/location'
|
3
|
-
require 'cucumber/core/ast/describes_itself'
|
4
|
-
require 'cucumber/core/ast/step'
|
5
|
-
|
6
|
-
module Cucumber
|
7
|
-
module Core
|
8
|
-
module Ast
|
9
|
-
|
10
|
-
class OutlineStep
|
11
|
-
include HasLocation
|
12
|
-
include DescribesItself
|
13
|
-
|
14
|
-
attr_reader :language, :location, :comments, :keyword, :text, :multiline_arg
|
15
|
-
|
16
|
-
def initialize(language, location, comments, keyword, text, multiline_arg)
|
17
|
-
@language, @location, @comments, @keyword, @text, @multiline_arg = language, location, comments, keyword, text, multiline_arg
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_step(row)
|
21
|
-
Ast::ExpandedOutlineStep.new(self, language, row.location, comments, keyword, row.expand(text), replace_multiline_arg(row))
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_s
|
25
|
-
text
|
26
|
-
end
|
27
|
-
|
28
|
-
def inspect
|
29
|
-
keyword_and_text = [keyword, text].join(": ")
|
30
|
-
%{#<#{self.class} "#{keyword_and_text}" (#{location})>}
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def description_for_visitors
|
36
|
-
:outline_step
|
37
|
-
end
|
38
|
-
|
39
|
-
def children
|
40
|
-
# TODO remove duplication with Step
|
41
|
-
# TODO spec
|
42
|
-
[@multiline_arg]
|
43
|
-
end
|
44
|
-
|
45
|
-
def replace_multiline_arg(example_row)
|
46
|
-
return unless multiline_arg
|
47
|
-
multiline_arg.map { |cell| example_row.expand(cell) }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'cucumber/core/ast/describes_itself'
|
3
|
-
require 'cucumber/core/ast/names'
|
4
|
-
require 'cucumber/core/ast/empty_background'
|
5
|
-
require 'cucumber/core/ast/location'
|
6
|
-
|
7
|
-
module Cucumber
|
8
|
-
module Core
|
9
|
-
module Ast
|
10
|
-
class Scenario
|
11
|
-
include Names
|
12
|
-
include HasLocation
|
13
|
-
include DescribesItself
|
14
|
-
|
15
|
-
attr_reader :location, :background,
|
16
|
-
:comments, :tags, :keyword,
|
17
|
-
:description, :raw_steps
|
18
|
-
private :raw_steps
|
19
|
-
|
20
|
-
def initialize(location, comments, tags, keyword, name, description, steps)
|
21
|
-
@location = location
|
22
|
-
@comments = comments
|
23
|
-
@tags = tags
|
24
|
-
@keyword = keyword
|
25
|
-
@name = name
|
26
|
-
@description = description
|
27
|
-
@raw_steps = steps
|
28
|
-
end
|
29
|
-
|
30
|
-
def children
|
31
|
-
raw_steps
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def description_for_visitors
|
37
|
-
:scenario
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,45 +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 ScenarioOutline
|
10
|
-
include Names
|
11
|
-
include HasLocation
|
12
|
-
include DescribesItself
|
13
|
-
|
14
|
-
MissingExamples = Class.new(StandardError)
|
15
|
-
|
16
|
-
attr_reader :comments, :tags, :keyword,
|
17
|
-
:steps, :examples_tables, :line
|
18
|
-
private :line
|
19
|
-
|
20
|
-
def initialize(location, comments, tags, keyword, name, description, steps, examples)
|
21
|
-
@location = location
|
22
|
-
@comments = comments
|
23
|
-
@tags = tags
|
24
|
-
@keyword = keyword
|
25
|
-
@name = name
|
26
|
-
@description = description
|
27
|
-
@steps = steps
|
28
|
-
@examples_tables = examples
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def children
|
34
|
-
@steps + @examples_tables
|
35
|
-
end
|
36
|
-
|
37
|
-
def description_for_visitors
|
38
|
-
:scenario_outline
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|