cucumber-cucumber-expressions 14.0.0 → 15.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/cucumber/cucumber_expressions/parameter_type_registry.rb +7 -0
- data/spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb +8 -9
- data/spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb +21 -19
- data/spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb +8 -9
- data/spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb +27 -0
- data/spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb +0 -5
- data/spec/cucumber/cucumber_expressions/regular_expression_spec.rb +10 -10
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 828b10c145b74d1c95557eb7388501f95b224f9178e252c739c3c885f2c2af57
|
4
|
+
data.tar.gz: 64cd2ed8ff725bddb920c6578031cbf9f4c8ac29dcad8027dab71ac06b8e1f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a1936372d073be75fc22ef38fdf16913cdcb3b52efb2192fd6755624c544b7c6c6551971682bde60ee4501c23a078ab0d6946e642a6c307e0236e7ab22b1f35
|
7
|
+
data.tar.gz: 217d4ba38d8e5793d29bec8708ce90b9504f8f0848578df0d247201fb7893dae74dd4a0d9bd0d01b852d3085a24faa8ed4aff8a8ef058d3587e91ae6b9aad3d0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
15.0.1
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'cucumber/cucumber_expressions/parameter_type'
|
2
2
|
require 'cucumber/cucumber_expressions/errors'
|
3
3
|
require 'cucumber/cucumber_expressions/cucumber_expression_generator'
|
4
|
+
require 'bigdecimal'
|
4
5
|
|
5
6
|
module Cucumber
|
6
7
|
module CucumberExpressions
|
@@ -20,6 +21,12 @@ module Cucumber
|
|
20
21
|
define_parameter_type(ParameterType.new('word', WORD_REGEXP, String, lambda {|s = nil| s}, false, false))
|
21
22
|
define_parameter_type(ParameterType.new('string', STRING_REGEXP, String, lambda { |s1, s2| arg = s1 != nil ? s1 : s2; arg.gsub(/\\"/, '"').gsub(/\\'/, "'")}, true, false))
|
22
23
|
define_parameter_type(ParameterType.new('', ANONYMOUS_REGEXP, String, lambda {|s = nil| s}, false, true))
|
24
|
+
define_parameter_type(ParameterType.new('bigdecimal', FLOAT_REGEXP, BigDecimal, lambda {|s = nil| BigDecimal(s)}, false, false))
|
25
|
+
define_parameter_type(ParameterType.new('biginteger', INTEGER_REGEXPS, Integer, lambda {|s = nil| s && s.to_i}, false, false))
|
26
|
+
define_parameter_type(ParameterType.new('byte', INTEGER_REGEXPS, Integer, lambda {|s = nil| s && s.to_i}, false, false))
|
27
|
+
define_parameter_type(ParameterType.new('short', INTEGER_REGEXPS, Integer, lambda {|s = nil| s && s.to_i}, false, false))
|
28
|
+
define_parameter_type(ParameterType.new('long', INTEGER_REGEXPS, Integer, lambda {|s = nil| s && s.to_i}, false, false))
|
29
|
+
define_parameter_type(ParameterType.new('double', FLOAT_REGEXP, Float, lambda {|s = nil| s && s.to_f}, false, false))
|
23
30
|
end
|
24
31
|
|
25
32
|
def lookup_by_type_name(name)
|
@@ -1,21 +1,20 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'json'
|
3
2
|
require 'cucumber/cucumber_expressions/cucumber_expression_parser'
|
4
3
|
require 'cucumber/cucumber_expressions/errors'
|
5
4
|
|
6
5
|
module Cucumber
|
7
6
|
module CucumberExpressions
|
8
|
-
describe
|
9
|
-
Dir['../testdata/
|
10
|
-
expectation = YAML.load_file(
|
11
|
-
it "#{
|
7
|
+
describe CucumberExpressionParser do
|
8
|
+
Dir['../testdata/cucumber-expression/parser/*.yaml'].each do |path|
|
9
|
+
expectation = YAML.load_file(path)
|
10
|
+
it "parses #{path}" do
|
12
11
|
parser = CucumberExpressionParser.new
|
13
|
-
if expectation['exception']
|
12
|
+
if expectation['exception']
|
13
|
+
expect { parser.parse(expectation['expression']) }.to raise_error(expectation['exception'])
|
14
|
+
else
|
14
15
|
node = parser.parse(expectation['expression'])
|
15
16
|
node_hash = node.to_hash
|
16
|
-
expect(node_hash).to eq(
|
17
|
-
else
|
18
|
-
expect { parser.parse(expectation['expression']) }.to raise_error(expectation['exception'])
|
17
|
+
expect(node_hash).to eq(expectation['expected_ast'])
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'json'
|
3
2
|
require 'cucumber/cucumber_expressions/cucumber_expression'
|
4
3
|
require 'cucumber/cucumber_expressions/parameter_type_registry'
|
5
4
|
|
@@ -7,33 +6,36 @@ module Cucumber
|
|
7
6
|
module CucumberExpressions
|
8
7
|
describe CucumberExpression do
|
9
8
|
|
10
|
-
Dir['../testdata/expression/*.yaml'].each do |
|
11
|
-
expectation = YAML.load_file(
|
12
|
-
it "#{
|
9
|
+
Dir['../testdata/cucumber-expression/matching/*.yaml'].each do |path|
|
10
|
+
expectation = YAML.load_file(path)
|
11
|
+
it "matches #{path}" do
|
13
12
|
parameter_registry = ParameterTypeRegistry.new
|
14
|
-
if expectation['exception']
|
15
|
-
cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
|
16
|
-
matches = cucumber_expression.match(expectation['text'])
|
17
|
-
values = matches.nil? ? nil : matches.map { |arg| arg.value(nil) }
|
18
|
-
expect(values).to eq(JSON.parse(expectation['expected']))
|
19
|
-
else
|
13
|
+
if expectation['exception']
|
20
14
|
expect {
|
21
15
|
cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
|
22
16
|
cucumber_expression.match(expectation['text'])
|
23
17
|
}.to raise_error(expectation['exception'])
|
18
|
+
else
|
19
|
+
cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
|
20
|
+
matches = cucumber_expression.match(expectation['text'])
|
21
|
+
values = matches.nil? ? nil : matches.map do |arg|
|
22
|
+
value = arg.value(nil)
|
23
|
+
case value
|
24
|
+
when BigDecimal
|
25
|
+
# Format {bigdecimal} as string (because it must be a string in matches-bigdecimal.yaml)
|
26
|
+
value.to_s('f')
|
27
|
+
when Integer
|
28
|
+
# Format {bigint} as string (because it must be a string in matches-bigint.yaml)
|
29
|
+
value.bit_length > 64 ? value.to_s : value
|
30
|
+
else
|
31
|
+
value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
expect(values).to eq(expectation['expected_args'])
|
24
35
|
end
|
25
36
|
end
|
26
37
|
end
|
27
38
|
|
28
|
-
Dir['../testdata/regex/*.yaml'].each do |testcase|
|
29
|
-
expectation = YAML.load_file(testcase) # encoding?
|
30
|
-
it "#{testcase}" do
|
31
|
-
parameter_registry = ParameterTypeRegistry.new
|
32
|
-
cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
|
33
|
-
expect(cucumber_expression.regexp.source).to eq(expectation['expected'])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
39
|
it "documents match arguments" do
|
38
40
|
parameter_registry = ParameterTypeRegistry.new
|
39
41
|
|
@@ -1,21 +1,20 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'json'
|
3
2
|
require 'cucumber/cucumber_expressions/cucumber_expression_tokenizer'
|
4
3
|
require 'cucumber/cucumber_expressions/errors'
|
5
4
|
|
6
5
|
module Cucumber
|
7
6
|
module CucumberExpressions
|
8
|
-
describe
|
9
|
-
Dir['../testdata/
|
10
|
-
expectation = YAML.load_file(
|
11
|
-
it "#{
|
7
|
+
describe CucumberExpressionTokenizer do
|
8
|
+
Dir['../testdata/cucumber-expression/tokenizer/*.yaml'].each do |path|
|
9
|
+
expectation = YAML.load_file(path)
|
10
|
+
it "tokenizes #{path}" do
|
12
11
|
tokenizer = CucumberExpressionTokenizer.new
|
13
|
-
if expectation['exception']
|
12
|
+
if expectation['exception']
|
13
|
+
expect { tokenizer.tokenize(expectation['expression']) }.to raise_error(expectation['exception'])
|
14
|
+
else
|
14
15
|
tokens = tokenizer.tokenize(expectation['expression'])
|
15
16
|
token_hashes = tokens.map{|token| token.to_hash}
|
16
|
-
expect(token_hashes).to eq(
|
17
|
-
else
|
18
|
-
expect { tokenizer.tokenize(expectation['expression']) }.to raise_error(expectation['exception'])
|
17
|
+
expect(token_hashes).to eq(expectation['expected_tokens'])
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cucumber/cucumber_expressions/cucumber_expression'
|
3
|
+
require 'cucumber/cucumber_expressions/parameter_type_registry'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module CucumberExpressions
|
7
|
+
describe CucumberExpression do
|
8
|
+
Dir['../testdata/cucumber-expression/transformation/*.yaml'].each do |path|
|
9
|
+
expectation = YAML.load_file(path)
|
10
|
+
it "transforms #{path}" do
|
11
|
+
parameter_registry = ParameterTypeRegistry.new
|
12
|
+
if expectation['exception']
|
13
|
+
expect {
|
14
|
+
cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
|
15
|
+
cucumber_expression.match(expectation['text'])
|
16
|
+
}.to raise_error(expectation['exception'])
|
17
|
+
else
|
18
|
+
cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
|
19
|
+
matches = cucumber_expression.match(expectation['text'])
|
20
|
+
values = matches.nil? ? nil : matches.map { |arg| arg.value(nil) }
|
21
|
+
expect(values).to eq(expectation['expected_args'])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -7,13 +7,10 @@ module Cucumber
|
|
7
7
|
class Color
|
8
8
|
attr_reader :name
|
9
9
|
|
10
|
-
### [color-constructor]
|
11
10
|
def initialize(name)
|
12
11
|
@name = name
|
13
12
|
end
|
14
13
|
|
15
|
-
### [color-constructor]
|
16
|
-
|
17
14
|
def ==(other)
|
18
15
|
other.is_a?(Color) && other.name == name
|
19
16
|
end
|
@@ -46,7 +43,6 @@ module Cucumber
|
|
46
43
|
describe "Custom parameter type" do
|
47
44
|
before do
|
48
45
|
parameter_type_registry = ParameterTypeRegistry.new
|
49
|
-
### [add-color-parameter-type]
|
50
46
|
parameter_type_registry.define_parameter_type(ParameterType.new(
|
51
47
|
'color', # name
|
52
48
|
/red|blue|yellow/, # regexp
|
@@ -55,7 +51,6 @@ module Cucumber
|
|
55
51
|
true, # use_for_snippets
|
56
52
|
false # prefer_for_regexp_match
|
57
53
|
))
|
58
|
-
### [add-color-parameter-type]
|
59
54
|
@parameter_type_registry = parameter_type_registry
|
60
55
|
end
|
61
56
|
|
@@ -1,19 +1,19 @@
|
|
1
|
+
require 'yaml'
|
1
2
|
require 'cucumber/cucumber_expressions/regular_expression'
|
2
3
|
require 'cucumber/cucumber_expressions/parameter_type_registry'
|
3
4
|
|
4
5
|
module Cucumber
|
5
6
|
module CucumberExpressions
|
6
7
|
describe RegularExpression do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
### [capture-match-arguments]
|
8
|
+
Dir['../testdata/regular-expression/matching/*.yaml'].each do |path|
|
9
|
+
expectation = YAML.load_file(path)
|
10
|
+
it "matches #{path}" do
|
11
|
+
parameter_registry = ParameterTypeRegistry.new
|
12
|
+
expression = RegularExpression.new(Regexp.new(expectation['expression']), parameter_registry)
|
13
|
+
matches = expression.match(expectation['text'])
|
14
|
+
values = matches.map { |arg| arg.value(nil) }
|
15
|
+
expect(values).to eq(expectation['expected_args'])
|
16
|
+
end
|
17
17
|
end
|
18
18
|
|
19
19
|
it "does no transform by default" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-cucumber-expressions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 15.0.1
|
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: 2022-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb
|
89
89
|
- spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb
|
90
90
|
- spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb
|
91
|
+
- spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb
|
91
92
|
- spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb
|
92
93
|
- spec/cucumber/cucumber_expressions/expression_factory_spec.rb
|
93
94
|
- spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb
|
@@ -122,7 +123,7 @@ requirements: []
|
|
122
123
|
rubygems_version: 3.2.22
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
|
-
summary: cucumber-expressions-
|
126
|
+
summary: cucumber-expressions-15.0.1
|
126
127
|
test_files:
|
127
128
|
- spec/capture_warnings.rb
|
128
129
|
- spec/cucumber/cucumber_expressions/argument_spec.rb
|
@@ -131,6 +132,7 @@ test_files:
|
|
131
132
|
- spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb
|
132
133
|
- spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb
|
133
134
|
- spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb
|
135
|
+
- spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb
|
134
136
|
- spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb
|
135
137
|
- spec/cucumber/cucumber_expressions/expression_factory_spec.rb
|
136
138
|
- spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb
|