cucumber-expressions 6.0.1 → 6.6.2
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/.rsync +1 -1
- data/.subrepo +1 -1
- data/.travis.yml +20 -13
- data/Makefile +1 -8
- data/README.md +1 -1
- data/cucumber-expressions.gemspec +9 -1
- data/default.mk +33 -0
- data/examples.txt +12 -0
- data/lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb +10 -1
- data/lib/cucumber/cucumber_expressions/cucumber_expression.rb +17 -4
- data/lib/cucumber/cucumber_expressions/parameter_type_matcher.rb +8 -1
- data/lib/cucumber/cucumber_expressions/parameter_type_registry.rb +13 -7
- data/lib/cucumber/cucumber_expressions/tree_regexp.rb +7 -2
- data/spec/capture_warnings.rb +3 -3
- data/spec/coverage.rb +1 -0
- data/spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb +46 -4
- data/spec/cucumber/cucumber_expressions/cucumber_expression_regexp_spec.rb +7 -0
- data/spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb +8 -0
- data/spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb +1 -1
- data/spec/cucumber/cucumber_expressions/regular_expression_spec.rb +4 -0
- data/spec/cucumber/cucumber_expressions/tree_regexp_spec.rb +8 -0
- metadata +11 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1c9bb3c99f56112e47e4b97965dad048c1817e76e5f4ed0f270e519132eb86f
|
|
4
|
+
data.tar.gz: 8004b7f168e0b6a35b5d58f9d7582b87daca2b3c35b8bffaa32e2d1e25e87a96
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 320da65062874ccecd9131884d5c972ff1c73b748617dbd6aae6566d2d01f489997dc024530152d66f3dfed7c44f140ffee4a78141cc6845ea5122a42df1d090
|
|
7
|
+
data.tar.gz: 3c0bdf0c5270ed65247bfec949c48eea39e1aba8d6e35300c63efd0cd5e7783079690a3098818ae5eeb0021fba38fb32d94fa3e720d7576a4e862895e31a154f
|
data/.rsync
CHANGED
data/.subrepo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
cucumber/cucumber-expressions-ruby
|
|
1
|
+
cucumber/cucumber-expressions-ruby
|
data/.travis.yml
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
# Please update /.templates/ruby/.travis.yml in the cucumber/cucumber monorepo
|
|
2
|
-
# and sync:
|
|
3
|
-
#
|
|
4
|
-
# source scripts/functions.sh && rsync_files
|
|
5
|
-
#
|
|
6
1
|
sudo: false
|
|
7
2
|
language: ruby
|
|
8
|
-
|
|
9
3
|
rvm:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
- 2.5.3
|
|
5
|
+
- 2.4.5
|
|
6
|
+
- 2.3.8
|
|
7
|
+
- jruby-9.2.0.0
|
|
8
|
+
script: make default
|
|
9
|
+
matrix:
|
|
10
|
+
allow_failures:
|
|
11
|
+
- rvm: jruby-9.2.0.0
|
|
12
|
+
jobs:
|
|
13
|
+
include:
|
|
14
|
+
- stage: deploy
|
|
15
|
+
ruby: 2.5.3
|
|
16
|
+
deploy:
|
|
17
|
+
skip_cleanup: true
|
|
18
|
+
provider: rubygems
|
|
19
|
+
gem: cucumber-expressions
|
|
20
|
+
on:
|
|
21
|
+
tags: true
|
|
22
|
+
api_key:
|
|
23
|
+
secure: qe+bx0MBxImttvjLt5TVkxWlanjPkSLzqmI6q3LlrhDcNiEy7jEJhBWEdVWWD3l6FG/1AY+XN1o18Re7eaAuun8C8QKmT6MjyMsYlf4bXMH2kfJ0IeRuNne1JRSvqVG6rAlVYHvHGJsReWGwfLAxvaEN0xAmx0cTW2MAmswUtV0LWFqMohV83Vbdcgsdvk2VMvtrtWuZTGod/o1QtcIcVimdnOjvdT79lo60IjgSa+tS7B7hEoehPa1kXZs5QYMEBhZOdIxG0rXCbIzz9wAY/4V4Z2F7SaPNBCuDZXz8Fmv9ZrAEYRsPGnNAbhLX3LFpxUEzmyHwubRRIysFCXrjgDakj4oSBiYAQResGqU0EBcbLiub1rNT72XpXbydI3N8NDdLg2CyZlAE83r7aTkEPdTvNoNwVfLQxpzP9GDKAFj5Fz4VdR0BiGhB+C5uqacpRByjiOyP2G8m2sqQhW6nTxYh61ZjCb38OLlHkdi2t7qECDD8ALlTgWPiVoeFz/cH7wVQR5dD5LoFXCq/BmOoOVGdYc8VbRyy/MPJWEepxK+v0j+LQlAwZdrtqvnE9fYKh8spQQ5+WQi5MfPWJzeXl+SzRFp5l380C3HpjYT4G/5TUaLlPzkPtpehsft9AwqgWiBvuhje2P+MesRk/tUtlWitBrpVLKCG+Dnt2fzhXIE=
|
data/Makefile
CHANGED
data/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/cucumber/cucumber-expressions-ruby)
|
|
4
4
|
|
|
5
|
-
[The docs are here](
|
|
5
|
+
[The docs are here](https://docs.cucumber.io/cucumber/cucumber-expressions/).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
Gem::Specification.new do |s|
|
|
3
3
|
s.name = 'cucumber-expressions'
|
|
4
|
-
s.version = '6.
|
|
4
|
+
s.version = '6.6.2'
|
|
5
5
|
s.authors = ["Aslak Hellesøy"]
|
|
6
6
|
s.description = 'Cucumber Expressions - a simpler alternative to Regular Expressions'
|
|
7
7
|
s.summary = "cucumber-expressions-#{s.version}"
|
|
@@ -11,6 +11,14 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.license = "MIT"
|
|
12
12
|
s.required_ruby_version = ">= 1.9.3"
|
|
13
13
|
|
|
14
|
+
s.metadata = {
|
|
15
|
+
'bug_tracker_uri' => 'https://github.com/cucumber/cucumber/issues',
|
|
16
|
+
'changelog_uri' => 'https://github.com/cucumber/cucumber/blob/master/cucumber-expressions/CHANGELOG.md',
|
|
17
|
+
'documentation_uri' => 'https://docs.cucumber.io/cucumber/cucumber-expressions/',
|
|
18
|
+
'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/cukes',
|
|
19
|
+
'source_code_uri' => 'https://github.com/cucumber/cucumber/blob/master/cucumber-expressions/ruby',
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
s.add_development_dependency 'bundler'
|
|
15
23
|
s.add_development_dependency 'rake', '~> 12.3'
|
|
16
24
|
s.add_development_dependency 'rspec', '~> 3.7'
|
data/default.mk
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
SHELL := /usr/bin/env bash
|
|
2
|
+
RUBY_SOURCE_FILES = $(shell find . -name "*.rb")
|
|
3
|
+
GEMSPECS = $(shell find . -name "*.gemspec")
|
|
4
|
+
|
|
5
|
+
ifdef TRAVIS_BRANCH
|
|
6
|
+
LIBRARY_VERSION=$(TRAVIS_BRANCH)
|
|
7
|
+
endif
|
|
8
|
+
ifdef TRAVIS_TAG
|
|
9
|
+
LIBRARY_VERSION=$(TRAVIS_TAG)
|
|
10
|
+
endif
|
|
11
|
+
ifndef LIBRARY_VERSION
|
|
12
|
+
LIBRARY_VERSION=$(shell git rev-parse --abbrev-ref HEAD)
|
|
13
|
+
endif
|
|
14
|
+
|
|
15
|
+
default: .tested
|
|
16
|
+
.PHONY: default
|
|
17
|
+
|
|
18
|
+
.deps: Gemfile.lock
|
|
19
|
+
|
|
20
|
+
Gemfile.lock: Gemfile $(GEMSPECS)
|
|
21
|
+
bundle install
|
|
22
|
+
touch $@
|
|
23
|
+
|
|
24
|
+
.tested: .deps $(RUBY_SOURCE_FILES)
|
|
25
|
+
bundle exec rspec --color
|
|
26
|
+
touch $@
|
|
27
|
+
|
|
28
|
+
clean: clean-ruby
|
|
29
|
+
.PHONY: clean
|
|
30
|
+
|
|
31
|
+
clean-ruby:
|
|
32
|
+
rm -f .deps .linked .tested Gemfile.lock
|
|
33
|
+
.PHONY: clean-ruby
|
data/examples.txt
CHANGED
|
@@ -17,3 +17,15 @@ I have 1 cuke in my belly now
|
|
|
17
17
|
/^Something( with an optional argument)?$/
|
|
18
18
|
Something
|
|
19
19
|
[null]
|
|
20
|
+
---
|
|
21
|
+
Привет, {word}!
|
|
22
|
+
Привет, Мир!
|
|
23
|
+
["Мир"]
|
|
24
|
+
---
|
|
25
|
+
/I have (.*) cukes? in my (.*) now/
|
|
26
|
+
I have 22 cukes in my belly now
|
|
27
|
+
["22","belly"]
|
|
28
|
+
---
|
|
29
|
+
I have {} cuke(s) in my {} now
|
|
30
|
+
I have 22 cukes in my belly now
|
|
31
|
+
["22","belly"]
|
|
@@ -15,9 +15,14 @@ module Cucumber
|
|
|
15
15
|
generated_expressions
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
# 256 generated expressions ought to be enough for anybody
|
|
19
|
+
MAX_EXPRESSIONS = 256
|
|
19
20
|
|
|
20
21
|
def generate_permutations(generated_expressions, depth, current_parameter_types)
|
|
22
|
+
if generated_expressions.length >= MAX_EXPRESSIONS
|
|
23
|
+
return
|
|
24
|
+
end
|
|
25
|
+
|
|
21
26
|
if depth == @parameter_type_combinations.length
|
|
22
27
|
generated_expression = GeneratedExpression.new(@expression_template, current_parameter_types)
|
|
23
28
|
generated_expressions.push(generated_expression)
|
|
@@ -25,6 +30,10 @@ module Cucumber
|
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
(0...@parameter_type_combinations[depth].length).each do |i|
|
|
33
|
+
# Avoid recursion if no elements can be added.
|
|
34
|
+
if generated_expressions.length >= MAX_EXPRESSIONS
|
|
35
|
+
return
|
|
36
|
+
end
|
|
28
37
|
new_current_parameter_types = current_parameter_types.dup # clone
|
|
29
38
|
new_current_parameter_types.push(@parameter_type_combinations[depth][i])
|
|
30
39
|
generate_permutations(
|
|
@@ -7,7 +7,7 @@ module Cucumber
|
|
|
7
7
|
class CucumberExpression
|
|
8
8
|
# Does not include (){} characters because they have special meaning
|
|
9
9
|
ESCAPE_REGEXP = /([\\^\[$.|?*+\]])/
|
|
10
|
-
PARAMETER_REGEXP = /(\\\\)?{([^}]
|
|
10
|
+
PARAMETER_REGEXP = /(\\\\)?{([^}]*)}/
|
|
11
11
|
OPTIONAL_REGEXP = /(\\\\)?\(([^)]+)\)/
|
|
12
12
|
ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP = /([^\s^\/]+)((\/[^\s^\/]+)+)/
|
|
13
13
|
DOUBLE_ESCAPE = '\\\\'
|
|
@@ -19,7 +19,7 @@ module Cucumber
|
|
|
19
19
|
def initialize(expression, parameter_type_registry)
|
|
20
20
|
@source = expression
|
|
21
21
|
@parameter_types = []
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
expression = process_escapes(expression)
|
|
24
24
|
expression = process_optional(expression)
|
|
25
25
|
expression = process_alternation(expression)
|
|
@@ -51,9 +51,22 @@ module Cucumber
|
|
|
51
51
|
# Create non-capturing, optional capture groups from parenthesis
|
|
52
52
|
expression.gsub(OPTIONAL_REGEXP) do
|
|
53
53
|
g2 = $2
|
|
54
|
-
|
|
54
|
+
# When using Parameter Types, the () characters are used to represent an optional
|
|
55
|
+
# item such as (a ) which would be equivalent to (?:a )? in regex
|
|
56
|
+
#
|
|
57
|
+
# You cannot have optional Parameter Types i.e. ({int}) as this causes
|
|
58
|
+
# problems during the conversion phase to regex. So we check for that here
|
|
59
|
+
#
|
|
60
|
+
# One exclusion to this rule is if you actually want the brackets i.e. you
|
|
61
|
+
# want to capture (3) then we still permit this as an individual rule
|
|
62
|
+
# See: https://github.com/cucumber/cucumber-ruby/issues/1337 for more info
|
|
55
63
|
# look for double-escaped parentheses
|
|
56
|
-
$1 == DOUBLE_ESCAPE
|
|
64
|
+
if $1 == DOUBLE_ESCAPE
|
|
65
|
+
"\\(#{g2}\\)"
|
|
66
|
+
else
|
|
67
|
+
check_no_parameter_type(g2, PARAMETER_TYPES_CANNOT_BE_OPTIONAL)
|
|
68
|
+
"(?:#{g2})?"
|
|
69
|
+
end
|
|
57
70
|
end
|
|
58
71
|
end
|
|
59
72
|
|
|
@@ -9,7 +9,14 @@ module Cucumber
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def advance_to(new_match_position)
|
|
12
|
-
|
|
12
|
+
(new_match_position...@text.length).each {|advancedPos|
|
|
13
|
+
matcher = self.class.new(parameter_type, @regexp, @text, advancedPos)
|
|
14
|
+
if matcher.find
|
|
15
|
+
return matcher
|
|
16
|
+
end
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
self.class.new(parameter_type, @regexp, @text, @text.length)
|
|
13
20
|
end
|
|
14
21
|
|
|
15
22
|
def find
|
|
@@ -7,17 +7,19 @@ module Cucumber
|
|
|
7
7
|
class ParameterTypeRegistry
|
|
8
8
|
INTEGER_REGEXPS = [/-?\d+/, /\d+/]
|
|
9
9
|
FLOAT_REGEXP = /-?\d*\.\d+/
|
|
10
|
-
WORD_REGEXP =
|
|
10
|
+
WORD_REGEXP = /[^\s]+/
|
|
11
11
|
STRING_REGEXP = /"([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)'/
|
|
12
|
+
ANONYMOUS_REGEXP = /.*/
|
|
12
13
|
|
|
13
14
|
def initialize
|
|
14
15
|
@parameter_type_by_name = {}
|
|
15
16
|
@parameter_types_by_regexp = Hash.new {|hash, regexp| hash[regexp] = []}
|
|
16
17
|
|
|
17
|
-
define_parameter_type(ParameterType.new('int', INTEGER_REGEXPS, Integer, lambda {|s=nil| s && s.to_i}, true, true))
|
|
18
|
-
define_parameter_type(ParameterType.new('float', FLOAT_REGEXP, Float, lambda {|s=nil| s && s.to_f}, true, false))
|
|
19
|
-
define_parameter_type(ParameterType.new('word', WORD_REGEXP, String, lambda {|s=nil| s}, false, false))
|
|
20
|
-
define_parameter_type(ParameterType.new('string', STRING_REGEXP, String, lambda {|s=nil| s && s.gsub(/\\"/, '"').gsub(/\\'/, "'")}, true, false))
|
|
18
|
+
define_parameter_type(ParameterType.new('int', INTEGER_REGEXPS, Integer, lambda {|s = nil| s && s.to_i}, true, true))
|
|
19
|
+
define_parameter_type(ParameterType.new('float', FLOAT_REGEXP, Float, lambda {|s = nil| s && s.to_f}, true, false))
|
|
20
|
+
define_parameter_type(ParameterType.new('word', WORD_REGEXP, String, lambda {|s = nil| s}, false, false))
|
|
21
|
+
define_parameter_type(ParameterType.new('string', STRING_REGEXP, String, lambda {|s = nil| s && s.gsub(/\\"/, '"').gsub(/\\'/, "'")}, true, false))
|
|
22
|
+
define_parameter_type(ParameterType.new('', ANONYMOUS_REGEXP, String, lambda {|s = nil| s}, false, true))
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def lookup_by_type_name(name)
|
|
@@ -42,9 +44,13 @@ module Cucumber
|
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def define_parameter_type(parameter_type)
|
|
45
|
-
if parameter_type.name
|
|
47
|
+
if parameter_type.name != nil
|
|
46
48
|
if @parameter_type_by_name.has_key?(parameter_type.name)
|
|
47
|
-
|
|
49
|
+
if parameter_type.name.length == 0
|
|
50
|
+
raise CucumberExpressionError.new("The anonymous parameter type has already been defined")
|
|
51
|
+
else
|
|
52
|
+
raise CucumberExpressionError.new("There is already a parameter with name #{parameter_type.name}")
|
|
53
|
+
end
|
|
48
54
|
end
|
|
49
55
|
@parameter_type_by_name[parameter_type.name] = parameter_type
|
|
50
56
|
end
|
|
@@ -13,13 +13,18 @@ module Cucumber
|
|
|
13
13
|
last = nil
|
|
14
14
|
escaping = false
|
|
15
15
|
non_capturing_maybe = false
|
|
16
|
+
char_class = false
|
|
16
17
|
|
|
17
18
|
@regexp.source.split('').each_with_index do |c, n|
|
|
18
|
-
if c == '
|
|
19
|
+
if c == '[' && !escaping
|
|
20
|
+
char_class = true
|
|
21
|
+
elsif c == ']' && !escaping
|
|
22
|
+
char_class = false
|
|
23
|
+
elsif c == '(' && !escaping && !char_class
|
|
19
24
|
stack.push(GroupBuilder.new)
|
|
20
25
|
group_start_stack.push(n+1)
|
|
21
26
|
non_capturing_maybe = false
|
|
22
|
-
elsif c == ')' && !escaping
|
|
27
|
+
elsif c == ')' && !escaping && !char_class
|
|
23
28
|
gb = stack.pop
|
|
24
29
|
group_start = group_start_stack.pop
|
|
25
30
|
if gb.capturing?
|
data/spec/capture_warnings.rb
CHANGED
|
@@ -13,7 +13,7 @@ module CaptureWarnings
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
if other_warnings.any?
|
|
16
|
-
puts "#{ other_warnings.count }
|
|
16
|
+
puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them."
|
|
17
17
|
print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS']
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -23,7 +23,7 @@ module CaptureWarnings
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
if project_warnings.any?
|
|
26
|
-
puts "#{ project_warnings.count }
|
|
26
|
+
puts "#{ project_warnings.count } warnings detected"
|
|
27
27
|
print_warnings('cucumber-expressions', project_warnings)
|
|
28
28
|
fail "Please remove all cucumber-expressions warnings."
|
|
29
29
|
end
|
|
@@ -35,7 +35,7 @@ module CaptureWarnings
|
|
|
35
35
|
old_stderr = STDERR.clone
|
|
36
36
|
pipe_r, pipe_w = IO.pipe
|
|
37
37
|
pipe_r.sync = true
|
|
38
|
-
error
|
|
38
|
+
error = String.new
|
|
39
39
|
reader = Thread.new do
|
|
40
40
|
begin
|
|
41
41
|
loop do
|
data/spec/coverage.rb
CHANGED
|
@@ -98,7 +98,7 @@ module Cucumber
|
|
|
98
98
|
expect(types).to eq([Integer, Float])
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
it "
|
|
101
|
+
it "matches parameter types with optional capture groups" do
|
|
102
102
|
@parameter_type_registry.define_parameter_type(ParameterType.new(
|
|
103
103
|
'optional-flight',
|
|
104
104
|
/(1st flight)?/,
|
|
@@ -116,15 +116,57 @@ module Cucumber
|
|
|
116
116
|
false
|
|
117
117
|
))
|
|
118
118
|
|
|
119
|
-
expression = @generator.generate_expressions("I reach Stage4: 1st flight-1st
|
|
120
|
-
expect
|
|
119
|
+
expression = @generator.generate_expressions("I reach Stage4: 1st flight-1st hotel")[0]
|
|
120
|
+
# While you would expect this to be `I reach Stage{int}: {optional-flight}-{optional-hotel}`
|
|
121
|
+
# the `-1` causes {int} to match just before {optional-hotel}.
|
|
122
|
+
expect(expression.source).to eq("I reach Stage{int}: {optional-flight}{int}st hotel")
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "generates at most 256 expressions" do
|
|
126
|
+
for i in 0..3
|
|
127
|
+
@parameter_type_registry.define_parameter_type(ParameterType.new(
|
|
128
|
+
"my-type-#{i}",
|
|
129
|
+
/[a-z]/,
|
|
130
|
+
String,
|
|
131
|
+
lambda {|s| s},
|
|
132
|
+
true,
|
|
133
|
+
false
|
|
134
|
+
))
|
|
135
|
+
end
|
|
136
|
+
# This would otherwise generate 4^11=419430 expressions and consume just shy of 1.5GB.
|
|
137
|
+
expressions = @generator.generate_expressions("a simple step")
|
|
138
|
+
expect(expressions.length).to eq(256)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "prefers expression with longest non empty match" do
|
|
142
|
+
@parameter_type_registry.define_parameter_type(ParameterType.new(
|
|
143
|
+
'zero-or-more',
|
|
144
|
+
/[a-z]*/,
|
|
145
|
+
String,
|
|
146
|
+
lambda {|s| s},
|
|
147
|
+
true,
|
|
148
|
+
false
|
|
149
|
+
))
|
|
150
|
+
@parameter_type_registry.define_parameter_type(ParameterType.new(
|
|
151
|
+
'exactly-one',
|
|
152
|
+
/[a-z]/,
|
|
153
|
+
String,
|
|
154
|
+
lambda {|s| s},
|
|
155
|
+
true,
|
|
156
|
+
false
|
|
157
|
+
))
|
|
158
|
+
|
|
159
|
+
expressions = @generator.generate_expressions("a simple step")
|
|
160
|
+
expect(expressions.length).to eq(2)
|
|
161
|
+
expect(expressions[0].source).to eq("{exactly-one} {zero-or-more} {zero-or-more}")
|
|
162
|
+
expect(expressions[1].source).to eq("{zero-or-more} {zero-or-more} {zero-or-more}")
|
|
121
163
|
end
|
|
122
164
|
|
|
123
165
|
def assert_expression(expected_expression, expected_argument_names, text)
|
|
124
166
|
generated_expression = @generator.generate_expression(text)
|
|
125
167
|
expect(generated_expression.parameter_names).to eq(expected_argument_names)
|
|
126
168
|
expect(generated_expression.source).to eq(expected_expression)
|
|
127
|
-
|
|
169
|
+
|
|
128
170
|
cucumber_expression = CucumberExpression.new(generated_expression.source, @parameter_type_registry)
|
|
129
171
|
match = cucumber_expression.match(text)
|
|
130
172
|
if match.nil?
|
|
@@ -76,6 +76,10 @@ module Cucumber
|
|
|
76
76
|
expect(match("{float}", ".22")).to eq([0.22])
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
it "matches anonymous" do
|
|
80
|
+
expect(match("{}", "0.22")).to eq(["0.22"])
|
|
81
|
+
end
|
|
82
|
+
|
|
79
83
|
'[]()$.|?*+'.split('').each do |char|
|
|
80
84
|
it "does not allow parameter type with #{char}" do
|
|
81
85
|
expect {match("{#{char}string}", "something")}.to raise_error("Illegal character '#{char}' in parameter name {#{char}string}")
|
|
@@ -90,6 +94,10 @@ module Cucumber
|
|
|
90
94
|
expect {match("({int})", "3")}.to raise_error('Parameter types cannot be optional: ({int})')
|
|
91
95
|
end
|
|
92
96
|
|
|
97
|
+
it "does allow escaped optional parameter types" do
|
|
98
|
+
expect(match("\\({int})", "(3)")).to eq([3])
|
|
99
|
+
end
|
|
100
|
+
|
|
93
101
|
it "does not allow text/parameter type alternation" do
|
|
94
102
|
expect {match("x/{int}", "3")}.to raise_error('Parameter types cannot be alternative: x/{int}')
|
|
95
103
|
end
|
|
@@ -20,6 +20,10 @@ module Cucumber
|
|
|
20
20
|
expect( match(/(\d\d)/, "22") ).to eq(["22"])
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
it "does not transform anonymous" do
|
|
24
|
+
expect( match(/(.*)/, "22") ).to eq(["22"])
|
|
25
|
+
end
|
|
26
|
+
|
|
23
27
|
it "transforms negative int" do
|
|
24
28
|
expect( match(/(-?\d+)/, "-22") ).to eq([-22])
|
|
25
29
|
end
|
|
@@ -85,6 +85,14 @@ module Cucumber
|
|
|
85
85
|
expect(group.value).to eq("hello")
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
it('does not consider parenthesis in character class as group') do
|
|
89
|
+
tr = TreeRegexp.new(/^drawings: ([A-Z_, ()]+)$/)
|
|
90
|
+
group = tr.match('drawings: ONE, TWO(ABC)')
|
|
91
|
+
expect(group.value).to eq('drawings: ONE, TWO(ABC)')
|
|
92
|
+
expect(group.children[0].value).to eq('ONE, TWO(ABC)')
|
|
93
|
+
expect(group.children.length).to eq(1)
|
|
94
|
+
end
|
|
95
|
+
|
|
88
96
|
it 'throws an error when there are named capture groups because they are buggy in Ruby' do
|
|
89
97
|
# https://github.com/cucumber/cucumber/issues/329
|
|
90
98
|
expect {
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cucumber-expressions
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aslak Hellesøy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- README.md
|
|
85
85
|
- Rakefile
|
|
86
86
|
- cucumber-expressions.gemspec
|
|
87
|
+
- default.mk
|
|
87
88
|
- examples.txt
|
|
88
89
|
- lib/cucumber/cucumber_expressions/argument.rb
|
|
89
90
|
- lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb
|
|
@@ -113,7 +114,12 @@ files:
|
|
|
113
114
|
homepage: https://github.com/cucumber/cucumber-expressions-ruby#readme
|
|
114
115
|
licenses:
|
|
115
116
|
- MIT
|
|
116
|
-
metadata:
|
|
117
|
+
metadata:
|
|
118
|
+
bug_tracker_uri: https://github.com/cucumber/cucumber/issues
|
|
119
|
+
changelog_uri: https://github.com/cucumber/cucumber/blob/master/cucumber-expressions/CHANGELOG.md
|
|
120
|
+
documentation_uri: https://docs.cucumber.io/cucumber/cucumber-expressions/
|
|
121
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
|
|
122
|
+
source_code_uri: https://github.com/cucumber/cucumber/blob/master/cucumber-expressions/ruby
|
|
117
123
|
post_install_message:
|
|
118
124
|
rdoc_options:
|
|
119
125
|
- "--charset=UTF-8"
|
|
@@ -130,11 +136,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
130
136
|
- !ruby/object:Gem::Version
|
|
131
137
|
version: '0'
|
|
132
138
|
requirements: []
|
|
133
|
-
|
|
134
|
-
rubygems_version: 2.7.6
|
|
139
|
+
rubygems_version: 3.0.3
|
|
135
140
|
signing_key:
|
|
136
141
|
specification_version: 4
|
|
137
|
-
summary: cucumber-expressions-6.
|
|
142
|
+
summary: cucumber-expressions-6.6.2
|
|
138
143
|
test_files:
|
|
139
144
|
- spec/capture_warnings.rb
|
|
140
145
|
- spec/coverage.rb
|