cucumber-cucumber-expressions 14.0.0 → 15.2.0

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: a32df17b80432aa451bc8f8d5822dfa3b919e44a3feefd657d6dffc730ca56c4
4
- data.tar.gz: 12157d0f708a0eaff7b0fc6ad1afb0b68668dfdfd87a370091466cae29d3fcfe
3
+ metadata.gz: 0bdeb47f27f47df87456711f1efa4a343a8f643041a9e3aa3b7c06f5ba45d718
4
+ data.tar.gz: ccd1faff1edfa0392d5e0a9f98e7f87df4b38fbf162d48368120007be7a0739c
5
5
  SHA512:
6
- metadata.gz: 95c6db3127e8a2111ec7f50b06dab07443649e2fd1f759818552df4ac24ec715bd8fb4aad2bd79b3e8054d88dc9751594c75880fa3c15b06f000c82dd88bb37e
7
- data.tar.gz: 59ba7dabc703d4b3f4ce6e0d319c0275dfa1dc78b0589544a51f5a070f8a3c6c183dcf0bfa60dbac168209944ee9f5ce95a7ed280f4b5f5f28c817b84b40a937
6
+ metadata.gz: a4f16a4e6094de191d31454f45cc1173feebfaa4f9b8fea908c560481e203cc6618a1b3022f32f32470a6e37b95d2b31f7ea156c33731e047b9e99589c01229c
7
+ data.tar.gz: fc7048862a358a5c7e98b7002ca823123a7c3272e6da49994526edd4c5ced67662224be9da9c44881918a649f65f26bdf4d524c3c544abdd3051479a51c75dbb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 14.0.0
1
+ 15.2.0
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  }
24
24
 
25
25
  s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
26
- s.add_development_dependency 'rspec', '~> 3.10', '>= 3.10.0'
26
+ s.add_development_dependency 'rspec', '~> 3.11', '>= 3.11.0'
27
27
 
28
28
  s.rubygems_version = ">= 1.6.1"
29
29
  s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ }
@@ -32,7 +32,7 @@ module Cucumber
32
32
  end
33
33
 
34
34
  def to_s
35
- @source.inspect
35
+ source.inspect
36
36
  end
37
37
 
38
38
  private
@@ -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
 
@@ -93,6 +95,11 @@ module Cucumber
93
95
  expect(CucumberExpression.new(expr, ParameterTypeRegistry.new).source).to eq(expr)
94
96
  end
95
97
 
98
+ it "exposes source via #to_s" do
99
+ expr = "I have {int} cuke(s)"
100
+ expect(CucumberExpression.new(expr, ParameterTypeRegistry.new).to_s).to eq(expr.inspect)
101
+ end
102
+
96
103
  it "unmatched optional groups have undefined values" do
97
104
  parameter_type_registry = ParameterTypeRegistry.new
98
105
  parameter_type_registry.define_parameter_type(
@@ -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: 14.0.0
4
+ version: 15.2.0
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-10-12 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -36,20 +36,20 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '3.10'
39
+ version: '3.11'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 3.10.0
42
+ version: 3.11.0
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '3.10'
49
+ version: '3.11'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 3.10.0
52
+ version: 3.11.0
53
53
  description: Cucumber Expressions - a simpler alternative to Regular Expressions
54
54
  email: cukes@googlegroups.com
55
55
  executables: []
@@ -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-14.0.0
126
+ summary: cucumber-expressions-15.2.0
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