cucumber-cucumber-expressions 13.1.1 → 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/README.md +1 -1
- 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 -5
- data/Makefile +0 -1
- data/default.mk +0 -93
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/README.md
CHANGED
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
|
@@ -59,12 +59,10 @@ files:
|
|
59
59
|
- ".rspec"
|
60
60
|
- Gemfile
|
61
61
|
- LICENSE
|
62
|
-
- Makefile
|
63
62
|
- README.md
|
64
63
|
- Rakefile
|
65
64
|
- VERSION
|
66
65
|
- cucumber-cucumber-expressions.gemspec
|
67
|
-
- default.mk
|
68
66
|
- lib/cucumber/cucumber_expressions/argument.rb
|
69
67
|
- lib/cucumber/cucumber_expressions/ast.rb
|
70
68
|
- lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb
|
@@ -90,6 +88,7 @@ files:
|
|
90
88
|
- spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb
|
91
89
|
- spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb
|
92
90
|
- spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb
|
91
|
+
- spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb
|
93
92
|
- spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb
|
94
93
|
- spec/cucumber/cucumber_expressions/expression_factory_spec.rb
|
95
94
|
- spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb
|
@@ -124,7 +123,7 @@ requirements: []
|
|
124
123
|
rubygems_version: 3.2.22
|
125
124
|
signing_key:
|
126
125
|
specification_version: 4
|
127
|
-
summary: cucumber-expressions-
|
126
|
+
summary: cucumber-expressions-15.0.1
|
128
127
|
test_files:
|
129
128
|
- spec/capture_warnings.rb
|
130
129
|
- spec/cucumber/cucumber_expressions/argument_spec.rb
|
@@ -133,6 +132,7 @@ test_files:
|
|
133
132
|
- spec/cucumber/cucumber_expressions/cucumber_expression_parser_spec.rb
|
134
133
|
- spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb
|
135
134
|
- spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb
|
135
|
+
- spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb
|
136
136
|
- spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb
|
137
137
|
- spec/cucumber/cucumber_expressions/expression_factory_spec.rb
|
138
138
|
- spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb
|
data/Makefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
include default.mk
|
data/default.mk
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
SHELL := /usr/bin/env bash
|
2
|
-
RUBY_SOURCE_FILES = $(shell find . -name "*.rb")
|
3
|
-
GEMSPEC = $(shell find . -name "*.gemspec")
|
4
|
-
LIBNAME := $(shell basename $$(dirname $$(pwd)))
|
5
|
-
GEM := cucumber-$(LIBNAME)-$(NEW_VERSION).gem
|
6
|
-
IS_TESTDATA = $(findstring -testdata,${CURDIR})
|
7
|
-
|
8
|
-
# https://stackoverflow.com/questions/2483182/recursive-wildcards-in-gnu-make
|
9
|
-
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
|
10
|
-
|
11
|
-
default: .tested
|
12
|
-
.PHONY: default
|
13
|
-
|
14
|
-
.deps: Gemfile.lock
|
15
|
-
touch $@
|
16
|
-
|
17
|
-
Gemfile.lock: Gemfile $(GEMSPEC)
|
18
|
-
bundle install
|
19
|
-
touch $@
|
20
|
-
|
21
|
-
.tested: .deps $(RUBY_SOURCE_FILES)
|
22
|
-
bundle exec rspec --color
|
23
|
-
touch $@
|
24
|
-
|
25
|
-
update-dependencies:
|
26
|
-
./scripts/update-gemspec
|
27
|
-
.PHONY: update-dependencies
|
28
|
-
|
29
|
-
ifdef NEW_VERSION
|
30
|
-
ifneq (,$(GEMSPEC))
|
31
|
-
gem: $(GEM)
|
32
|
-
else
|
33
|
-
gem:
|
34
|
-
@echo "Not building gem because there is no gemspec"
|
35
|
-
endif
|
36
|
-
endif
|
37
|
-
.PHONY: gem
|
38
|
-
|
39
|
-
$(GEM): .tested
|
40
|
-
gem build $(GEMSPEC)
|
41
|
-
test -s "$(GEM)" || { echo "Gem not built: $(GEM)"; exit 1; }
|
42
|
-
|
43
|
-
remove-local-dependencies:
|
44
|
-
cat Gemfile | sed 's/^gem /#gem /' > Gemfile.tmp
|
45
|
-
mv Gemfile.tmp Gemfile
|
46
|
-
.PHONY: remove-local-dependencies
|
47
|
-
|
48
|
-
pre-release: remove-local-dependencies update-version update-dependencies gem
|
49
|
-
.PHONY: pre-release
|
50
|
-
|
51
|
-
update-version:
|
52
|
-
ifeq ($(IS_TESTDATA),-testdata)
|
53
|
-
# no-op
|
54
|
-
else
|
55
|
-
ifdef NEW_VERSION
|
56
|
-
@echo "$(NEW_VERSION)" > VERSION
|
57
|
-
endif
|
58
|
-
endif
|
59
|
-
.PHONY: update-version
|
60
|
-
|
61
|
-
publish: gem
|
62
|
-
ifeq ($(IS_TESTDATA),-testdata)
|
63
|
-
# no-op
|
64
|
-
else
|
65
|
-
ifneq (,$(GEMSPEC))
|
66
|
-
gem push $(GEM)
|
67
|
-
else
|
68
|
-
@echo "Not publishing because there is no gemspec"
|
69
|
-
endif
|
70
|
-
endif
|
71
|
-
.PHONY: publish
|
72
|
-
|
73
|
-
post-release:
|
74
|
-
cat Gemfile | sed 's/^#gem /gem /' > Gemfile.tmp
|
75
|
-
mv Gemfile.tmp Gemfile
|
76
|
-
.PHONY: post-release
|
77
|
-
|
78
|
-
clean: clean-ruby
|
79
|
-
.PHONY: clean
|
80
|
-
|
81
|
-
clean-ruby:
|
82
|
-
rm -rf .deps .linked .tested* Gemfile.lock *.gem acceptance
|
83
|
-
.PHONY: clean-ruby
|
84
|
-
|
85
|
-
### COMMON stuff for all platforms
|
86
|
-
|
87
|
-
BERP_VERSION = 1.3.0
|
88
|
-
BERP_GRAMMAR = gherkin.berp
|
89
|
-
|
90
|
-
define berp-generate-parser =
|
91
|
-
-! dotnet tool list --tool-path /usr/bin | grep "berp\s*$(BERP_VERSION)" && dotnet tool update Berp --version $(BERP_VERSION) --tool-path /usr/bin
|
92
|
-
berp -g $(BERP_GRAMMAR) -t $< -o $@ --noBOM
|
93
|
-
endef
|