cucumber-gherkin 28.0.0 → 30.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.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/bin/gherkin +20 -19
- data/lib/gherkin/ast_builder.rb +22 -15
- data/lib/gherkin/dialect.rb +2 -1
- data/lib/gherkin/errors.rb +1 -1
- data/lib/gherkin/gherkin-languages.json +23 -24
- data/lib/gherkin/gherkin_line.rb +4 -5
- data/lib/gherkin/parser.rb +371 -371
- data/lib/gherkin/pickles/compiler.rb +4 -7
- data/lib/gherkin/query.rb +4 -0
- data/lib/gherkin/stream/parser_message_stream.rb +15 -14
- data/lib/gherkin/token_formatter_builder.rb +9 -9
- data/lib/gherkin/token_matcher.rb +10 -12
- data/lib/gherkin/token_scanner.rb +2 -3
- data/lib/gherkin.rb +9 -11
- metadata +31 -42
- data/spec/capture_warnings.rb +0 -74
- data/spec/gherkin/dialect_spec.rb +0 -13
- data/spec/gherkin/gherkin_line_spec.rb +0 -36
- data/spec/gherkin/gherkin_spec.rb +0 -45
- data/spec/gherkin/parser_spec.rb +0 -10
- data/spec/gherkin/query_spec.rb +0 -208
- data/spec/gherkin/stream/parser_message_stream_spec.rb +0 -67
@@ -11,6 +11,7 @@ module Gherkin
|
|
11
11
|
pickles = []
|
12
12
|
|
13
13
|
return pickles unless gherkin_document.feature
|
14
|
+
|
14
15
|
feature = gherkin_document.feature
|
15
16
|
language = feature.language
|
16
17
|
tags = feature.tags
|
@@ -143,9 +144,7 @@ module Gherkin
|
|
143
144
|
type: keyword_type,
|
144
145
|
text: interpolate(step.text, variable_cells, value_cells),
|
145
146
|
}
|
146
|
-
if values_row
|
147
|
-
props[:ast_node_ids].push(values_row.id)
|
148
|
-
end
|
147
|
+
props[:ast_node_ids].push(values_row.id) if values_row
|
149
148
|
|
150
149
|
if step.data_table
|
151
150
|
data_table = Cucumber::Messages::PickleStepArgument.new(
|
@@ -180,14 +179,12 @@ module Gherkin
|
|
180
179
|
props = {
|
181
180
|
content: interpolate(doc_string.content, variable_cells, value_cells)
|
182
181
|
}
|
183
|
-
if doc_string.media_type
|
184
|
-
props[:media_type] = interpolate(doc_string.media_type, variable_cells, value_cells)
|
185
|
-
end
|
182
|
+
props[:media_type] = interpolate(doc_string.media_type, variable_cells, value_cells) if doc_string.media_type
|
186
183
|
Cucumber::Messages::PickleDocString.new(**props)
|
187
184
|
end
|
188
185
|
|
189
186
|
def pickle_tags(tags)
|
190
|
-
tags.map {|tag| pickle_tag(tag)}
|
187
|
+
tags.map { |tag| pickle_tag(tag) }
|
191
188
|
end
|
192
189
|
|
193
190
|
def pickle_tag(tag)
|
data/lib/gherkin/query.rb
CHANGED
@@ -12,11 +12,13 @@ module Gherkin
|
|
12
12
|
|
13
13
|
def scenario_parent_locations(scenario_node_id)
|
14
14
|
return @scenario_parent_locations[scenario_node_id] if @scenario_parent_locations.has_key?(scenario_node_id)
|
15
|
+
|
15
16
|
raise AstNodeNotLocatedException, "No scenario parent locations found for #{scenario_node_id} }. Known: #{@scenario_parent_locations.keys}"
|
16
17
|
end
|
17
18
|
|
18
19
|
def location(ast_node_id)
|
19
20
|
return @ast_node_locations[ast_node_id] if @ast_node_locations.has_key?(ast_node_id)
|
21
|
+
|
20
22
|
raise AstNodeNotLocatedException, "No location found for #{ast_node_id} }. Known: #{@ast_node_locations.keys}"
|
21
23
|
end
|
22
24
|
|
@@ -24,6 +26,7 @@ module Gherkin
|
|
24
26
|
|
25
27
|
def update_feature(feature)
|
26
28
|
return if feature.nil?
|
29
|
+
|
27
30
|
store_nodes_location(feature.tags)
|
28
31
|
|
29
32
|
feature.children.each do |child|
|
@@ -35,6 +38,7 @@ module Gherkin
|
|
35
38
|
|
36
39
|
def update_rule(feature, rule)
|
37
40
|
return if rule.nil?
|
41
|
+
|
38
42
|
store_nodes_location(rule.tags)
|
39
43
|
rule.children.each do |child|
|
40
44
|
update_background(rule, child.background) if child.background
|
@@ -11,37 +11,38 @@ module Gherkin
|
|
11
11
|
@sources = sources
|
12
12
|
@options = options
|
13
13
|
|
14
|
-
id_generator = options[:id_generator] || Cucumber::Messages::IdGenerator::UUID.new
|
14
|
+
id_generator = options[:id_generator] || Cucumber::Messages::Helpers::IdGenerator::UUID.new
|
15
15
|
@parser = Parser.new(AstBuilder.new(id_generator))
|
16
16
|
@compiler = Pickles::Compiler.new(id_generator)
|
17
17
|
end
|
18
18
|
|
19
19
|
def messages
|
20
20
|
enumerated = false
|
21
|
-
Enumerator.new do |
|
21
|
+
Enumerator.new do |yielder|
|
22
22
|
raise DoubleIterationException, "Messages have already been enumerated" if enumerated
|
23
|
+
|
23
24
|
enumerated = true
|
24
25
|
|
25
26
|
sources.each do |source|
|
26
|
-
|
27
|
+
yielder.yield(Cucumber::Messages::Envelope.new(source: source)) if @options[:include_source]
|
27
28
|
begin
|
28
29
|
gherkin_document = nil
|
29
30
|
|
30
31
|
if @options[:include_gherkin_document]
|
31
32
|
gherkin_document = build_gherkin_document(source)
|
32
|
-
|
33
|
+
yielder.yield(Cucumber::Messages::Envelope.new(gherkin_document: gherkin_document))
|
33
34
|
end
|
34
35
|
if @options[:include_pickles]
|
35
36
|
gherkin_document ||= build_gherkin_document(source)
|
36
37
|
pickles = @compiler.compile(gherkin_document, source)
|
37
38
|
pickles.each do |pickle|
|
38
|
-
|
39
|
+
yielder.yield(Cucumber::Messages::Envelope.new(pickle: pickle))
|
39
40
|
end
|
40
41
|
end
|
41
|
-
rescue CompositeParserException =>
|
42
|
-
yield_parse_errors(
|
43
|
-
rescue ParserException =>
|
44
|
-
yield_parse_errors(
|
42
|
+
rescue CompositeParserException => e
|
43
|
+
yield_parse_errors(yielder, e.errors, source.uri)
|
44
|
+
rescue ParserException => e
|
45
|
+
yield_parse_errors(yielder, [e], source.uri)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -49,7 +50,7 @@ module Gherkin
|
|
49
50
|
|
50
51
|
private
|
51
52
|
|
52
|
-
def yield_parse_errors(
|
53
|
+
def yield_parse_errors(yielder, errors, uri)
|
53
54
|
errors.each do |err|
|
54
55
|
parse_error = Cucumber::Messages::ParseError.new(
|
55
56
|
source: Cucumber::Messages::SourceReference.new(
|
@@ -61,22 +62,22 @@ module Gherkin
|
|
61
62
|
),
|
62
63
|
message: err.message
|
63
64
|
)
|
64
|
-
|
65
|
+
yielder.yield(Cucumber::Messages::Envelope.new(parse_error: parse_error))
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
69
|
def sources
|
69
|
-
Enumerator.new do |
|
70
|
+
Enumerator.new do |yielder|
|
70
71
|
@paths.each do |path|
|
71
72
|
source = Cucumber::Messages::Source.new(
|
72
73
|
uri: path,
|
73
74
|
data: File.open(path, 'r:UTF-8', &:read),
|
74
75
|
media_type: 'text/x.cucumber.gherkin+plain'
|
75
76
|
)
|
76
|
-
|
77
|
+
yielder.yield(source)
|
77
78
|
end
|
78
79
|
@sources.each do |source|
|
79
|
-
|
80
|
+
yielder.yield(source)
|
80
81
|
end
|
81
82
|
end
|
82
83
|
end
|
@@ -5,35 +5,35 @@ module Gherkin
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def reset
|
8
|
-
@tokens_text =
|
8
|
+
@tokens_text = ''
|
9
9
|
end
|
10
10
|
|
11
11
|
def build(token)
|
12
12
|
@tokens_text << "#{format_token(token)}\n"
|
13
13
|
end
|
14
14
|
|
15
|
-
def start_rule(
|
16
|
-
end
|
15
|
+
def start_rule(_rule_type); end
|
17
16
|
|
18
|
-
def end_rule(
|
19
|
-
end
|
17
|
+
def end_rule(_rule_type); end
|
20
18
|
|
21
19
|
def get_result
|
22
20
|
@tokens_text
|
23
21
|
end
|
24
22
|
|
25
23
|
private
|
24
|
+
|
26
25
|
def format_token(token)
|
27
|
-
return
|
26
|
+
return 'EOF' if token.eof?
|
28
27
|
|
29
|
-
sprintf
|
28
|
+
sprintf(
|
29
|
+
"(%s:%s)%s:%s/%s/%s",
|
30
30
|
token.location[:line],
|
31
31
|
token.location[:column],
|
32
32
|
token.matched_type,
|
33
33
|
token.matched_keyword ? sprintf("(%s)%s", token.matched_keyword_type, token.matched_keyword) : "",
|
34
34
|
token.matched_text,
|
35
|
-
Array(token.matched_items).map { |i| "#{i.column}:#{i.text}"}.join(',')
|
35
|
+
Array(token.matched_items).map { |i| "#{i.column}:#{i.text}" }.join(',')
|
36
|
+
)
|
36
37
|
end
|
37
|
-
|
38
38
|
end
|
39
39
|
end
|
@@ -48,21 +48,22 @@ module Gherkin
|
|
48
48
|
|
49
49
|
def match_TableRow(token)
|
50
50
|
return false unless token.line.start_with?('|')
|
51
|
-
|
52
|
-
set_token_matched(token, :TableRow, nil, nil, nil, nil,
|
53
|
-
token.line.table_cells)
|
51
|
+
|
52
|
+
set_token_matched(token, :TableRow, nil, nil, nil, nil, token.line.table_cells)
|
54
53
|
true
|
55
54
|
end
|
56
55
|
|
57
56
|
def match_Empty(token)
|
58
57
|
return false unless token.line.empty?
|
58
|
+
|
59
59
|
set_token_matched(token, :Empty, nil, nil, 0)
|
60
60
|
true
|
61
61
|
end
|
62
62
|
|
63
63
|
def match_Comment(token)
|
64
64
|
return false unless token.line.start_with?('#')
|
65
|
-
|
65
|
+
|
66
|
+
text = token.line.get_line_text(0) # take the entire line, including leading space
|
66
67
|
set_token_matched(token, :Comment, text, nil, 0)
|
67
68
|
true
|
68
69
|
end
|
@@ -70,7 +71,7 @@ module Gherkin
|
|
70
71
|
def match_Language(token)
|
71
72
|
return false unless token.line.trimmed_line_text =~ LANGUAGE_PATTERN
|
72
73
|
|
73
|
-
dialect_name =
|
74
|
+
dialect_name = Regexp.last_match(1)
|
74
75
|
set_token_matched(token, :Language, dialect_name)
|
75
76
|
|
76
77
|
change_dialect(dialect_name, token.location)
|
@@ -108,6 +109,7 @@ module Gherkin
|
|
108
109
|
|
109
110
|
def match_EOF(token)
|
110
111
|
return false unless token.eof?
|
112
|
+
|
111
113
|
set_token_matched(token, :EOF)
|
112
114
|
true
|
113
115
|
end
|
@@ -132,22 +134,18 @@ module Gherkin
|
|
132
134
|
title = token.line.get_rest_trimmed(keyword.length)
|
133
135
|
keyword_types = @keyword_types[keyword]
|
134
136
|
keyword_type = keyword_types[0]
|
135
|
-
if keyword_types.length
|
136
|
-
keyword_type = Cucumber::Messages::StepKeywordType::UNKNOWN
|
137
|
-
end
|
137
|
+
keyword_type = Cucumber::Messages::StepKeywordType::UNKNOWN if keyword_types.length > 1
|
138
138
|
|
139
139
|
set_token_matched(token,
|
140
140
|
:StepLine, title, keyword, nil, keyword_type)
|
141
|
-
|
141
|
+
true
|
142
142
|
end
|
143
143
|
|
144
144
|
private
|
145
145
|
|
146
146
|
def add_keyword_type_mappings(keywords, type)
|
147
147
|
keywords.each do |keyword|
|
148
|
-
|
149
|
-
@keyword_types[keyword] = []
|
150
|
-
end
|
148
|
+
@keyword_types[keyword] = [] unless @keyword_types.has_key?(keyword)
|
151
149
|
@keyword_types[keyword] += [type]
|
152
150
|
end
|
153
151
|
end
|
@@ -14,7 +14,7 @@ module Gherkin
|
|
14
14
|
def initialize(source_or_io)
|
15
15
|
@line_number = 0
|
16
16
|
|
17
|
-
case
|
17
|
+
case source_or_io
|
18
18
|
when String
|
19
19
|
@io = StringIO.new(source_or_io)
|
20
20
|
when StringIO, IO
|
@@ -25,7 +25,7 @@ module Gherkin
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def read
|
28
|
-
location = {line: @line_number += 1}
|
28
|
+
location = { line: @line_number += 1 }
|
29
29
|
if @io.nil? || line = @io.gets
|
30
30
|
gherkin_line = line ? GherkinLine.new(line, location[:line]) : nil
|
31
31
|
Token.new(gherkin_line, location)
|
@@ -35,6 +35,5 @@ module Gherkin
|
|
35
35
|
Token.new(nil, location)
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
38
|
end
|
40
39
|
end
|
data/lib/gherkin.rb
CHANGED
@@ -7,28 +7,26 @@ module Gherkin
|
|
7
7
|
include_pickles: true
|
8
8
|
}.freeze
|
9
9
|
|
10
|
-
def self.from_paths(paths, options={})
|
10
|
+
def self.from_paths(paths, options = {})
|
11
11
|
Stream::ParserMessageStream.new(
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
paths,
|
13
|
+
[],
|
14
|
+
options
|
15
15
|
).messages
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.from_sources(sources, options={})
|
18
|
+
def self.from_sources(sources, options = {})
|
19
19
|
Stream::ParserMessageStream.new(
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
[],
|
21
|
+
sources,
|
22
|
+
options
|
23
23
|
).messages
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.from_source(uri, data, options={})
|
26
|
+
def self.from_source(uri, data, options = {})
|
27
27
|
from_sources([encode_source_message(uri, data)], options)
|
28
28
|
end
|
29
29
|
|
30
|
-
private
|
31
|
-
|
32
30
|
def self.encode_source_message(uri, data)
|
33
31
|
Cucumber::Messages::Source.new(
|
34
32
|
uri: uri,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-gherkin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 30.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gáspár Nagy
|
@@ -10,68 +10,70 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-10-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cucumber-messages
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '25'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '28'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
|
-
- - "
|
29
|
+
- - ">"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version:
|
31
|
+
version: '25'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '28'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rake
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '13.
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: 13.0.6
|
41
|
+
version: '13.1'
|
45
42
|
type: :development
|
46
43
|
prerelease: false
|
47
44
|
version_requirements: !ruby/object:Gem::Requirement
|
48
45
|
requirements:
|
49
46
|
- - "~>"
|
50
47
|
- !ruby/object:Gem::Version
|
51
|
-
version: '13.
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 13.0.6
|
48
|
+
version: '13.1'
|
55
49
|
- !ruby/object:Gem::Dependency
|
56
50
|
name: rspec
|
57
51
|
requirement: !ruby/object:Gem::Requirement
|
58
52
|
requirements:
|
59
53
|
- - "~>"
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 3.11.0
|
55
|
+
version: '3.13'
|
65
56
|
type: :development
|
66
57
|
prerelease: false
|
67
58
|
version_requirements: !ruby/object:Gem::Requirement
|
68
59
|
requirements:
|
69
60
|
- - "~>"
|
70
61
|
- !ruby/object:Gem::Version
|
71
|
-
version: '3.
|
72
|
-
|
62
|
+
version: '3.13'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rubocop
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.26.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
73
75
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
76
|
+
version: 1.26.0
|
75
77
|
description: Gherkin parser
|
76
78
|
email: cukes@googlegroups.com
|
77
79
|
executables:
|
@@ -80,6 +82,7 @@ executables:
|
|
80
82
|
extensions: []
|
81
83
|
extra_rdoc_files: []
|
82
84
|
files:
|
85
|
+
- LICENSE
|
83
86
|
- README.md
|
84
87
|
- bin/gherkin
|
85
88
|
- bin/gherkin-ruby
|
@@ -98,13 +101,6 @@ files:
|
|
98
101
|
- lib/gherkin/token_formatter_builder.rb
|
99
102
|
- lib/gherkin/token_matcher.rb
|
100
103
|
- lib/gherkin/token_scanner.rb
|
101
|
-
- spec/capture_warnings.rb
|
102
|
-
- spec/gherkin/dialect_spec.rb
|
103
|
-
- spec/gherkin/gherkin_line_spec.rb
|
104
|
-
- spec/gherkin/gherkin_spec.rb
|
105
|
-
- spec/gherkin/parser_spec.rb
|
106
|
-
- spec/gherkin/query_spec.rb
|
107
|
-
- spec/gherkin/stream/parser_message_stream_spec.rb
|
108
104
|
homepage: https://github.com/cucumber/gherkin
|
109
105
|
licenses:
|
110
106
|
- MIT
|
@@ -123,22 +119,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
119
|
requirements:
|
124
120
|
- - ">="
|
125
121
|
- !ruby/object:Gem::Version
|
126
|
-
version: '
|
122
|
+
version: '3.0'
|
127
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
124
|
requirements:
|
129
125
|
- - ">="
|
130
126
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
127
|
+
version: 3.2.8
|
132
128
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.5.16
|
134
130
|
signing_key:
|
135
131
|
specification_version: 4
|
136
|
-
summary: cucumber-gherkin-
|
137
|
-
test_files:
|
138
|
-
- spec/capture_warnings.rb
|
139
|
-
- spec/gherkin/dialect_spec.rb
|
140
|
-
- spec/gherkin/gherkin_line_spec.rb
|
141
|
-
- spec/gherkin/gherkin_spec.rb
|
142
|
-
- spec/gherkin/parser_spec.rb
|
143
|
-
- spec/gherkin/query_spec.rb
|
144
|
-
- spec/gherkin/stream/parser_message_stream_spec.rb
|
132
|
+
summary: cucumber-gherkin-30.0.0
|
133
|
+
test_files: []
|
data/spec/capture_warnings.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# With thanks to @myronmarston
|
3
|
-
# https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb
|
4
|
-
|
5
|
-
module CaptureWarnings
|
6
|
-
def report_warnings(&block)
|
7
|
-
current_dir = Dir.pwd
|
8
|
-
warnings, errors = capture_error(&block).partition { |line| line.include?('warning') }
|
9
|
-
project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) }
|
10
|
-
|
11
|
-
if errors.any?
|
12
|
-
puts errors.join("\n")
|
13
|
-
end
|
14
|
-
|
15
|
-
if other_warnings.any?
|
16
|
-
puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them."
|
17
|
-
print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS']
|
18
|
-
end
|
19
|
-
|
20
|
-
# Until they fix https://bugs.ruby-lang.org/issues/10661
|
21
|
-
if RUBY_VERSION == "2.2.0"
|
22
|
-
project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ }
|
23
|
-
end
|
24
|
-
|
25
|
-
if project_warnings.any?
|
26
|
-
puts "#{ project_warnings.count } warnings detected"
|
27
|
-
print_warnings('cucumber-expressions', project_warnings)
|
28
|
-
fail "Please remove all cucumber-expressions warnings."
|
29
|
-
end
|
30
|
-
|
31
|
-
ensure_system_exit_if_required
|
32
|
-
end
|
33
|
-
|
34
|
-
def capture_error(&block)
|
35
|
-
old_stderr = STDERR.clone
|
36
|
-
pipe_r, pipe_w = IO.pipe
|
37
|
-
pipe_r.sync = true
|
38
|
-
error = String.new
|
39
|
-
reader = Thread.new do
|
40
|
-
begin
|
41
|
-
loop do
|
42
|
-
error << pipe_r.readpartial(1024)
|
43
|
-
end
|
44
|
-
rescue EOFError
|
45
|
-
end
|
46
|
-
end
|
47
|
-
STDERR.reopen(pipe_w)
|
48
|
-
block.call
|
49
|
-
ensure
|
50
|
-
capture_system_exit
|
51
|
-
STDERR.reopen(old_stderr)
|
52
|
-
pipe_w.close
|
53
|
-
reader.join
|
54
|
-
return error.split("\n")
|
55
|
-
end
|
56
|
-
|
57
|
-
def print_warnings(type, warnings)
|
58
|
-
puts
|
59
|
-
puts "-" * 30 + " #{type} warnings: " + "-" * 30
|
60
|
-
puts
|
61
|
-
puts warnings.join("\n")
|
62
|
-
puts
|
63
|
-
puts "-" * 75
|
64
|
-
puts
|
65
|
-
end
|
66
|
-
|
67
|
-
def ensure_system_exit_if_required
|
68
|
-
raise @system_exit if @system_exit
|
69
|
-
end
|
70
|
-
|
71
|
-
def capture_system_exit
|
72
|
-
@system_exit = $!
|
73
|
-
end
|
74
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'rspec'
|
3
|
-
require 'gherkin/dialect'
|
4
|
-
|
5
|
-
module Gherkin
|
6
|
-
describe Dialect do
|
7
|
-
it 'provides an interface to the keywords of a dialect' do
|
8
|
-
dialect_en = Dialect.for('en')
|
9
|
-
|
10
|
-
expect(dialect_en.feature_keywords).to eq(['Feature', 'Business Need', 'Ability'])
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'gherkin/gherkin_line'
|
3
|
-
|
4
|
-
describe Gherkin::GherkinLine do
|
5
|
-
context '#tags' do
|
6
|
-
def tags(line)
|
7
|
-
Gherkin::GherkinLine.new(line, 12).tags.map(&:text)
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'allows any non-space characters in a tag' do
|
11
|
-
expect(tags(" @foo:bar @zap🥒yo")).to eq(['@foo:bar', '@zap🥒yo'])
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context '#table_cells' do
|
16
|
-
def cells_text(line)
|
17
|
-
Gherkin::GherkinLine.new(line, 12).table_cells.map(&:text)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'trims white spaces before cell content' do
|
21
|
-
expect(cells_text("| \t spaces before|")).to eq(['spaces before'])
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'trims white spaces after cell content' do
|
25
|
-
expect(cells_text("|spaces after |")).to eq(['spaces after'])
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'trims white spaces around cell content' do
|
29
|
-
expect(cells_text("| \t spaces everywhere \t|")).to eq(['spaces everywhere'])
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'does not drop white spaces inside a cell' do
|
33
|
-
expect(cells_text("| foo()\n bar\nbaz |")).to eq(["foo()\n bar\nbaz"])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'gherkin'
|
3
|
-
|
4
|
-
describe Gherkin do
|
5
|
-
it "can process feature file paths" do
|
6
|
-
messages = Gherkin.from_paths(
|
7
|
-
["../testdata/good/minimal.feature"],
|
8
|
-
{include_source: true,
|
9
|
-
include_gherkin_document: true,
|
10
|
-
include_pickles: true}
|
11
|
-
).to_a
|
12
|
-
|
13
|
-
expect(messages.length).to eq(3)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "can process feature file content" do
|
17
|
-
data = File.open("../testdata/good/minimal.feature", 'r:UTF-8', &:read)
|
18
|
-
|
19
|
-
messages = Gherkin.from_source(
|
20
|
-
"uri",
|
21
|
-
data,
|
22
|
-
{include_source: true,
|
23
|
-
include_gherkin_document: true,
|
24
|
-
include_pickles: true}
|
25
|
-
).to_a
|
26
|
-
|
27
|
-
expect(messages.length).to eq(3)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "can set the default dialect for the feature file content" do
|
31
|
-
data = File.open("../testdata/good/i18n_no.feature", 'r:UTF-8', &:read)
|
32
|
-
data_without_language_header = data.split("\n")[1..-1].join("\n")
|
33
|
-
|
34
|
-
messages = Gherkin.from_source(
|
35
|
-
"uri",
|
36
|
-
data,
|
37
|
-
{include_source: true,
|
38
|
-
include_gherkin_document: true,
|
39
|
-
include_pickles: true,
|
40
|
-
default_dialect: "no"}
|
41
|
-
).to_a
|
42
|
-
|
43
|
-
expect(messages.length).to eq(3)
|
44
|
-
end
|
45
|
-
end
|