cucumber-cucumber-expressions 13.1.3 → 15.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b015bc63f3dc328fbeaaca9b20daf5e602f16f26cdfca8161ced76165397630f
4
- data.tar.gz: 422f74a5f429d13f1f5895e2f2acbf2e81140b325e09abfec2ca47f61c014aa7
3
+ metadata.gz: 2ef20202d47a4e26bfaad49aeae395550fdf1a676dfd4a20295fc037a534e2a1
4
+ data.tar.gz: 6e5e0cba8961035a9eae0bbf0377ca687e6a4636d3399710bd279edcc26eb93e
5
5
  SHA512:
6
- metadata.gz: 795cd977c9827da57538d3bcd955cefdf81db77e475a6924c61f6917fff5c65082452457af4a2e7c560c47221f797af232785e9a01a62c79070232827726c896
7
- data.tar.gz: bc55bfcaa4e6b190c53470c2ddaea86c78f1ccb82bdb343b519c5cd02ddd4b970065899ab4559f25aec9066c0c77901622560a520cea934d318feb5eb9a17858
6
+ metadata.gz: 4c8451036eeb1c7846a88dc2e16e7641446a8fbd4eb2b5a3909b77d3630ea26b47195c90061007820baab4d08e61ec38ee9031148f4daf08e8798982d5a5014d
7
+ data.tar.gz: 8600450db1083601afb7a7df6de20d9b9c5e10c165beb6bcd31bac244c299d580fa91088412f0882ab87c4f23cf0c74dbf1fa62d7921f198738dd5f6bacd2782
data/VERSION CHANGED
@@ -1 +1 @@
1
- 13.1.3
1
+ 15.0.2
@@ -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 'Cucumber expression parser' do
9
- Dir['../testdata/ast/*.yaml'].each do |testcase|
10
- expectation = YAML.load_file(testcase) # encoding?
11
- it "#{testcase}" do
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'].nil?
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(JSON.parse(expectation['expected']))
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 |testcase|
11
- expectation = YAML.load_file(testcase) # encoding?
12
- it "#{testcase}" do
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'].nil?
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 'Cucumber expression tokenizer' do
9
- Dir['../testdata/tokens/*.yaml'].each do |testcase|
10
- expectation = YAML.load_file(testcase) # encoding?
11
- it "#{testcase}" do
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'].nil?
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(JSON.parse(expectation['expected']))
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
- it "documents match arguments" do
8
- parameter_type_registry = ParameterTypeRegistry.new
9
-
10
- ### [capture-match-arguments]
11
- expr = /I have (\d+) cukes? in my (\w*) now/
12
- expression = RegularExpression.new(expr, parameter_type_registry)
13
- args = expression.match("I have 7 cukes in my belly now")
14
- expect( args[0].value(nil) ).to eq(7)
15
- expect( args[1].value(nil) ).to eq("belly")
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: 13.1.3
4
+ version: 15.0.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: 2021-09-24 00:00:00.000000000 Z
11
+ date: 2022-03-15 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-13.1.3
126
+ summary: cucumber-expressions-15.0.2
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