cucumber-expressions 4.0.0 → 4.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f97682c81c4fc810b23bb199a01196191dba087
4
- data.tar.gz: 7c29ceea697976f3de194014a9ff039f25478ffe
3
+ metadata.gz: d24725b82e154836aede4e4bb39e1c80ec664f0b
4
+ data.tar.gz: 91b3cc77505a06fd4ae831217b1ffe0155d33c14
5
5
  SHA512:
6
- metadata.gz: e3a91aeeae161ea22e6114c17ed13b3160eec652de6927cc45241772dd7c8121d620558339db2eb992652da21fa788efd6645636629b259888d23f24acd615f3
7
- data.tar.gz: 1f2ee3c5d76189bdf6c52c5bf86a2d485524ecaa2e8207cfe83d91ee7fafb1dda8c9f9d515ce6b8ee3326f59aa3d52a422da38dcf45be9c16e34483904b5cb1d
6
+ metadata.gz: f0450cd7e01c19b67ebbb1e4611340de9507ff2b7680bc2e07ba3a7d23ac39a0c18e528165e1ae61db2140329b85a1c3d452c6823f27eaec8a9422d2f71add4c
7
+ data.tar.gz: 49566f903a663bbbdc91ac517fe3a94340f6b333b417d19d1b6834cc149ace78da849ed9c8629315e1c349638f49bb4ff71ae1a51e72de7bb773491fe0093686
@@ -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 = '4.0.0'
4
+ s.version = '4.0.1'
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}"
@@ -4,16 +4,17 @@ require 'cucumber/cucumber_expressions/errors'
4
4
  module Cucumber
5
5
  module CucumberExpressions
6
6
  class Argument
7
- def self.build(regexp, text, parameter_types)
8
- m = regexp.match(text)
9
- return nil if m.nil?
7
+ attr_reader :group
10
8
 
11
- match_group = Group.new(m)
12
- arg_groups = match_group.children
9
+ def self.build(tree_regexp, text, parameter_types)
10
+ group = tree_regexp.match(text)
11
+ return nil if group.nil?
12
+
13
+ arg_groups = group.children
13
14
 
14
15
  if arg_groups.length != parameter_types.length
15
- raise CucumberExpressionException.new(
16
- "Expression has #{arg_groups.length} arguments, but there were #{parameter_types.length} parameter types"
16
+ raise CucumberExpressionError.new(
17
+ "Expression #{tree_regexp.regexp.inspect} has #{arg_groups.length} capture groups (#{arg_groups.map(&:value)}), but there were #{parameter_types.length} parameter types (#{parameter_types.map(&:name)})"
17
18
  )
18
19
  end
19
20
 
@@ -23,7 +24,6 @@ module Cucumber
23
24
  end
24
25
 
25
26
  def initialize(group, parameter_type)
26
- raise "WTF" if Array === group
27
27
  @group, @parameter_type = group, parameter_type
28
28
  end
29
29
 
@@ -1,11 +1,11 @@
1
1
  require 'cucumber/cucumber_expressions/argument'
2
- require 'cucumber/cucumber_expressions/parameter_type'
2
+ require 'cucumber/cucumber_expressions/tree_regexp'
3
3
  require 'cucumber/cucumber_expressions/errors'
4
4
 
5
5
  module Cucumber
6
6
  module CucumberExpressions
7
7
  class CucumberExpression
8
- PARAMETER_REGEXP = /\{([^}]+)}/
8
+ PARAMETER_REGEXP = /{([^}]+)}/
9
9
  OPTIONAL_REGEXP = /\(([^)]+)\)/
10
10
  ALTERNATIVE_WORD_REGEXP = /([[:alpha:]]+)((\/[[:alpha:]]+)+)/
11
11
 
@@ -14,7 +14,7 @@ module Cucumber
14
14
  def initialize(expression, parameter_type_registry)
15
15
  @source = expression
16
16
  @parameter_types = []
17
- regexp = "^"
17
+ regexp = '^'
18
18
  match_offset = 0
19
19
 
20
20
  # Escape Does not include (){} because they have special meaning
@@ -38,23 +38,31 @@ module Cucumber
38
38
  @parameter_types.push(parameter_type)
39
39
 
40
40
  text = expression.slice(match_offset...match.offset(0)[0])
41
- capture_regexp = regexp(parameter_type.regexps)
41
+ capture_regexp = build_capture_regexp(parameter_type.regexps)
42
42
  match_offset = match.offset(0)[1]
43
43
  regexp += text
44
44
  regexp += capture_regexp
45
45
  end
46
46
  regexp += expression.slice(match_offset..-1)
47
- regexp += "$"
48
- @regexp = Regexp.new(regexp)
47
+ regexp += '$'
48
+ @tree_regexp = TreeRegexp.new(regexp)
49
49
  end
50
50
 
51
51
  def match(text)
52
- Argument.build(@regexp, text, @parameter_types)
52
+ Argument.build(@tree_regexp, text, @parameter_types)
53
+ end
54
+
55
+ def regexp
56
+ @tree_regexp.regexp
57
+ end
58
+
59
+ def to_s
60
+ @source.inspect
53
61
  end
54
62
 
55
63
  private
56
64
 
57
- def regexp(regexps)
65
+ def build_capture_regexp(regexps)
58
66
  return "(#{regexps[0]})" if regexps.size == 1
59
67
  capture_groups = regexps.map { |group| "(?:#{group})" }
60
68
  "(#{capture_groups.join('|')})"
@@ -21,7 +21,7 @@ I couldn't decide which one to use. You have two options:
21
21
  1) Use a Cucumber Expression instead of a Regular Expression. Try one of these:
22
22
  #{expressions(generated_expressions)}
23
23
 
24
- 2) Make one of the parameter types prefer_for_regexp_match and continue to use a Regular Expression.
24
+ 2) Make one of the parameter types preferential and continue to use a Regular Expression.
25
25
 
26
26
  EOM
27
27
  end
@@ -1,66 +1,18 @@
1
1
  module Cucumber
2
2
  module CucumberExpressions
3
3
  class Group
4
- attr_reader :children, :start, :end, :value
4
+ attr_reader :value, :start, :end, :children
5
5
 
6
- def initialize(*args)
7
- @children = []
8
-
9
- if MatchData === args[0]
10
- match_data = args[0]
11
- parse(match_data)
12
- else
13
- @start = args[0] || -1
14
- @end = args[1] || -1
15
- @value = args[2]
16
- end
17
- end
18
-
19
- def contains?(group)
20
- group.null? || (group.start >= @start && group.end <= @end)
21
- end
22
-
23
- def add(group)
24
- @children.push(group)
25
- end
26
-
27
- def null?
28
- @value.nil?
6
+ def initialize(value, start, _end, children)
7
+ @value = value
8
+ @start = start
9
+ @end = _end
10
+ @children = children
29
11
  end
30
12
 
31
13
  def values
32
14
  (children.empty? ? [self] : children).map(&:value)
33
15
  end
34
-
35
- private
36
-
37
- def parse(match_data)
38
- if match_data.length == 1
39
- @start = @end = -1
40
- @value = nil
41
- return
42
- end
43
-
44
- @start = match_data.offset(0)[0]
45
- @end = match_data.offset(0)[1]
46
- @value = match_data[0]
47
-
48
- stack = []
49
- stack.push(self)
50
-
51
- (1...match_data.length).each do |group_index|
52
- group = Group.new(
53
- match_data.offset(group_index)[0],
54
- match_data.offset(group_index)[1],
55
- match_data[group_index]
56
- )
57
- while !stack.last.contains?(group)
58
- stack.pop
59
- end
60
- stack.last.add(group)
61
- stack.push(group)
62
- end
63
- end
64
16
  end
65
17
  end
66
18
  end
@@ -0,0 +1,36 @@
1
+ require 'cucumber/cucumber_expressions/group'
2
+
3
+ module Cucumber
4
+ module CucumberExpressions
5
+ class GroupBuilder
6
+ def initialize
7
+ @group_builders = []
8
+ @capturing = true
9
+ end
10
+
11
+ def add(group_builder)
12
+ @group_builders.push(group_builder)
13
+ end
14
+
15
+ def build(match, group_indices)
16
+ group_index = group_indices.next
17
+ children = @group_builders.map {|gb| gb.build(match, group_indices)}
18
+ Group.new(match[group_index], match.offset(group_index)[0], match.offset(group_index)[1], children)
19
+ end
20
+
21
+ def set_non_capturing!
22
+ @capturing = false
23
+ end
24
+
25
+ def capturing?
26
+ @capturing
27
+ end
28
+
29
+ def move_children_to(group_builder)
30
+ @group_builders.each do |child|
31
+ group_builder.add(child)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -6,7 +6,7 @@ module Cucumber
6
6
  module CucumberExpressions
7
7
  class ParameterTypeRegistry
8
8
  INTEGER_REGEXPS = [/-?\d+/, /\d+/]
9
- FLOAT_REGEXP = /-?\d*\.?\d+/
9
+ FLOAT_REGEXP = /-?\d*\.\d+/
10
10
  WORD_REGEXP = /\w+/
11
11
  STRING_REGEXP = /"([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)'/
12
12
 
@@ -50,7 +50,7 @@ module Cucumber
50
50
  parameter_type.regexps.each do |parameter_type_regexp|
51
51
  parameter_types = @parameter_types_by_regexp[parameter_type_regexp]
52
52
  if parameter_types.any? && parameter_types[0].prefer_for_regexp_match? && parameter_type.prefer_for_regexp_match?
53
- raise CucumberExpressionError.new("There can only be one prefer_for_regexp_match parameter type per regexp. The regexp /#{parameter_type_regexp}/ is used for two prefer_for_regexp_match parameter types, {#{parameter_types[0].name}} and {#{parameter_type.name}}")
53
+ raise CucumberExpressionError.new("There can only be one preferential parameter type per regexp. The regexp /#{parameter_type_regexp}/ is used for two preferential parameter types, {#{parameter_types[0].name}} and {#{parameter_type.name}}")
54
54
  end
55
55
  parameter_types.push(parameter_type)
56
56
  parameter_types.sort!
@@ -1,5 +1,6 @@
1
1
  require 'cucumber/cucumber_expressions/argument'
2
2
  require 'cucumber/cucumber_expressions/parameter_type'
3
+ require 'cucumber/cucumber_expressions/tree_regexp'
3
4
 
4
5
  module Cucumber
5
6
  module CucumberExpressions
@@ -9,6 +10,7 @@ module Cucumber
9
10
  def initialize(expression_regexp, parameter_type_registry)
10
11
  @expression_regexp = expression_regexp
11
12
  @parameter_type_registry = parameter_type_registry
13
+ @tree_regexp = TreeRegexp.new(@expression_regexp)
12
14
  end
13
15
 
14
16
  def match(text)
@@ -26,7 +28,7 @@ module Cucumber
26
28
  parameter_type = @parameter_type_registry.lookup_by_regexp(parameter_type_regexp, @expression_regexp, text)
27
29
  if parameter_type.nil?
28
30
  parameter_type = ParameterType.new(
29
- '*',
31
+ parameter_type_regexp,
30
32
  parameter_type_regexp,
31
33
  String,
32
34
  lambda {|s| s},
@@ -38,12 +40,20 @@ module Cucumber
38
40
  parameter_types.push(parameter_type)
39
41
  end
40
42
 
41
- Argument.build(@expression_regexp, text, parameter_types)
43
+ Argument.build(@tree_regexp, text, parameter_types)
42
44
  end
43
45
 
44
- def source
46
+ def regexp
45
47
  @expression_regexp
46
48
  end
49
+
50
+ def source
51
+ @expression_regexp.source
52
+ end
53
+
54
+ def to_s
55
+ regexp.inspect
56
+ end
47
57
  end
48
58
  end
49
59
  end
@@ -0,0 +1,46 @@
1
+ require 'cucumber/cucumber_expressions/group_builder'
2
+
3
+ module Cucumber
4
+ module CucumberExpressions
5
+ class TreeRegexp
6
+ attr_reader :regexp
7
+
8
+ def initialize(regexp)
9
+ @regexp = regexp.is_a?(Regexp) ? regexp : Regexp.new(regexp)
10
+
11
+ stack = [GroupBuilder.new]
12
+ last = nil
13
+ non_capturing_maybe = false
14
+ @regexp.source.split('').each do |c|
15
+ if c == '(' && last != '\\'
16
+ stack.push(GroupBuilder.new)
17
+ non_capturing_maybe = false
18
+ elsif c == ')' && last != '\\'
19
+ gb = stack.pop
20
+ if gb.capturing?
21
+ stack.last.add(gb)
22
+ else
23
+ gb.move_children_to(stack.last)
24
+ end
25
+ non_capturing_maybe = false
26
+ elsif c == '?' && last == '('
27
+ non_capturing_maybe = true
28
+ elsif c == ':' && non_capturing_maybe
29
+ stack.last.set_non_capturing!
30
+ non_capturing_maybe = false
31
+ end
32
+ last = c
33
+ end
34
+ @group_builder = stack.pop
35
+ end
36
+
37
+ def match(s)
38
+ match = @regexp.match(s)
39
+ return nil if match.nil?
40
+ group_indices = (0..match.length).to_a.to_enum
41
+ @group_builder.build(match, group_indices)
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -7,7 +7,7 @@ module Cucumber
7
7
  context "Regexp translation" do
8
8
  def assert_regexp(expression, regexp)
9
9
  cucumber_expression = CucumberExpression.new(expression, ParameterTypeRegistry.new)
10
- expect(regexp).to eq(cucumber_expression.instance_variable_get('@regexp'))
10
+ expect(regexp).to eq(cucumber_expression.regexp)
11
11
  end
12
12
 
13
13
  it "translates no arguments" do
@@ -27,7 +27,7 @@ module Cucumber
27
27
  it "translates parameters" do
28
28
  assert_regexp(
29
29
  "I have {float} cukes at {int} o'clock",
30
- /^I have (-?\d*\.?\d+) cukes at ((?:-?\d+)|(?:\d+)) o'clock$/
30
+ /^I have (-?\d*\.\d+) cukes at ((?:-?\d+)|(?:\d+)) o'clock$/
31
31
  )
32
32
  end
33
33
 
@@ -28,7 +28,7 @@ module Cucumber
28
28
  @registry.define_parameter_type(ParameterType.new("place", CAPITALISED_WORD, Place, lambda {|s| Place.new}, true, true))
29
29
  end.to raise_error(
30
30
  CucumberExpressionError,
31
- "There can only be one prefer_for_regexp_match parameter type per regexp. The regexp /[A-Z]+\\w+/ is used for two prefer_for_regexp_match parameter types, {name} and {place}"
31
+ "There can only be one preferential parameter type per regexp. The regexp /[A-Z]+\\w+/ is used for two preferential parameter types, {name} and {place}"
32
32
  )
33
33
  end
34
34
 
@@ -76,7 +76,7 @@ module Cucumber
76
76
  " {place} and {person}\n" +
77
77
  " {place} and {place}\n" +
78
78
  "\n" +
79
- "2) Make one of the parameter types prefer_for_regexp_match and continue to use a Regular Expression.\n" +
79
+ "2) Make one of the parameter types preferential and continue to use a Regular Expression.\n" +
80
80
  "\n"
81
81
  )
82
82
  end
@@ -29,11 +29,11 @@ module Cucumber
29
29
  end
30
30
 
31
31
  it "transforms float without integer part" do
32
- expect( match(/(-?\d*\.?\d+)/, ".22") ).to eq([0.22])
32
+ expect( match(/(-?\d*\.\d+)/, ".22") ).to eq([0.22])
33
33
  end
34
34
 
35
35
  it "transforms float with sign" do
36
- expect( match(/(-?\d*\.?\d+)/, "-1.22") ).to eq([-1.22])
36
+ expect( match(/(-?\d*\.\d+)/, "-1.22") ).to eq([-1.22])
37
37
  end
38
38
 
39
39
  it "returns nil when there is no match" do
@@ -42,14 +42,16 @@ module Cucumber
42
42
 
43
43
  it "ignores non capturing groups" do
44
44
  expect( match(
45
- /(\S+) ?(can|cannot)? (?:delete|cancel) the (\d+)(?:st|nd|rd|th) (attachment|slide) ?(?:upload)?/,
45
+ /(\S+) ?(can|cannot) (?:delete|cancel) the (\d+)(?:st|nd|rd|th) (attachment|slide) ?(?:upload)?/,
46
46
  "I can cancel the 1st slide upload")
47
47
  ).to eq(["I", "can", 1, "slide"])
48
48
  end
49
49
 
50
- it "exposes source" do
51
- expr = /I have (\d+) cukes? in my (\+) now/
52
- expect(RegularExpression.new(expr, ParameterTypeRegistry.new).source).to eq(expr)
50
+ it "exposes source and regexp" do
51
+ regexp = /I have (\d+) cukes? in my (\+) now/
52
+ expression = RegularExpression.new(regexp, ParameterTypeRegistry.new)
53
+ expect(expression.regexp).to eq(regexp)
54
+ expect(expression.source).to eq(regexp.source)
53
55
  end
54
56
 
55
57
  def match(expression, text)
@@ -0,0 +1,60 @@
1
+ require 'cucumber/cucumber_expressions/tree_regexp'
2
+
3
+ module Cucumber
4
+ module CucumberExpressions
5
+ describe TreeRegexp do
6
+ it 'builds tree' do
7
+ tr = TreeRegexp.new(/(a(?:b)?)(c)/)
8
+ group = tr.match('ac')
9
+ expect(group.value).to eq('ac')
10
+ expect(group.children[0].value).to eq('a')
11
+ expect(group.children[0].children).to eq([])
12
+ expect(group.children[1].value).to eq('c')
13
+ end
14
+
15
+ it 'ignores non-capturing groups' do
16
+ tr = TreeRegexp.new(/(a(?:b)?)(c)/)
17
+ group = tr.match('ac')
18
+ expect(group.value).to eq('ac')
19
+ expect(group.children[0].value).to eq('a')
20
+ expect(group.children[0].children).to eq([])
21
+ expect(group.children[1].value).to eq('c')
22
+ end
23
+
24
+ it 'matches optional group' do
25
+ tr = TreeRegexp.new(/^Something( with an optional argument)?/)
26
+ group = tr.match('Something')
27
+ expect(group.children[0].value).to eq(nil)
28
+ end
29
+
30
+ it 'matches nested groups' do
31
+ tr = TreeRegexp.new(/^A (\d+) thick line from ((\d+),\s*(\d+),\s*(\d+)) to ((\d+),\s*(\d+),\s*(\d+))/)
32
+ group = tr.match('A 5 thick line from 10,20,30 to 40,50,60')
33
+
34
+ expect(group.children[0].value).to eq('5')
35
+ expect(group.children[1].value).to eq('10,20,30')
36
+ expect(group.children[1].children[0].value).to eq('10')
37
+ expect(group.children[1].children[1].value).to eq('20')
38
+ expect(group.children[1].children[2].value).to eq('30')
39
+ expect(group.children[2].value).to eq('40,50,60')
40
+ expect(group.children[2].children[0].value).to eq('40')
41
+ expect(group.children[2].children[1].value).to eq('50')
42
+ expect(group.children[2].children[2].value).to eq('60')
43
+ end
44
+
45
+ it 'detects multiple non capturing groups' do
46
+ tr = TreeRegexp.new(/(?:a)(:b)(\?c)(d)/)
47
+ group = tr.match("a:b?cd")
48
+ expect(group.children.length).to eq(3)
49
+ end
50
+
51
+ it 'captures non capturing groups with capturing groups inside' do
52
+ tr = TreeRegexp.new("the stdout(?: from \"(.*?)\")?")
53
+ group = tr.match("the stdout")
54
+ expect(group.value).to eq("the stdout")
55
+ expect(group.children[0].value).to eq(nil)
56
+ expect(group.children.length).to eq(1)
57
+ end
58
+ end
59
+ end
60
+ end
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: 4.0.0
4
+ version: 4.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: 2017-06-28 00:00:00.000000000 Z
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,10 +89,12 @@ files:
89
89
  - lib/cucumber/cucumber_expressions/errors.rb
90
90
  - lib/cucumber/cucumber_expressions/generated_expression.rb
91
91
  - lib/cucumber/cucumber_expressions/group.rb
92
+ - lib/cucumber/cucumber_expressions/group_builder.rb
92
93
  - lib/cucumber/cucumber_expressions/parameter_type.rb
93
94
  - lib/cucumber/cucumber_expressions/parameter_type_matcher.rb
94
95
  - lib/cucumber/cucumber_expressions/parameter_type_registry.rb
95
96
  - lib/cucumber/cucumber_expressions/regular_expression.rb
97
+ - lib/cucumber/cucumber_expressions/tree_regexp.rb
96
98
  - spec/capture_warnings.rb
97
99
  - spec/coverage.rb
98
100
  - spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb
@@ -101,9 +103,9 @@ files:
101
103
  - spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb
102
104
  - spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb
103
105
  - spec/cucumber/cucumber_expressions/expression_examples_spec.rb
104
- - spec/cucumber/cucumber_expressions/group_spec.rb
105
106
  - spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb
106
107
  - spec/cucumber/cucumber_expressions/regular_expression_spec.rb
108
+ - spec/cucumber/cucumber_expressions/tree_regexp_spec.rb
107
109
  homepage: https://github.com/cucumber/cucumber-expressions-ruby#readme
108
110
  licenses:
109
111
  - MIT
@@ -128,7 +130,7 @@ rubyforge_project:
128
130
  rubygems_version: 2.6.8
129
131
  signing_key:
130
132
  specification_version: 4
131
- summary: cucumber-expressions-4.0.0
133
+ summary: cucumber-expressions-4.0.1
132
134
  test_files:
133
135
  - spec/capture_warnings.rb
134
136
  - spec/coverage.rb
@@ -138,6 +140,6 @@ test_files:
138
140
  - spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb
139
141
  - spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb
140
142
  - spec/cucumber/cucumber_expressions/expression_examples_spec.rb
141
- - spec/cucumber/cucumber_expressions/group_spec.rb
142
143
  - spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb
143
144
  - spec/cucumber/cucumber_expressions/regular_expression_spec.rb
145
+ - spec/cucumber/cucumber_expressions/tree_regexp_spec.rb
@@ -1,34 +0,0 @@
1
- require 'cucumber/cucumber_expressions/group'
2
-
3
- module Cucumber
4
- module CucumberExpressions
5
- describe Group do
6
- it 'matches optional group' do
7
- regexp = /^Something( with an optional argument)?/
8
- string = 'Something'
9
- matches = regexp.match(string)
10
- group = Group.new(matches, string)
11
-
12
- expect(group.children[0].value).to eq(nil)
13
- end
14
-
15
- it 'matches nested groups' do
16
- regexp = /^A (\d+) thick line from ((\d+),\s*(\d+),\s*(\d+)) to ((\d+),\s*(\d+),\s*(\d+))?/
17
- string = 'A 5 thick line from 10,20,30 to 40,50,60'
18
-
19
- matches = regexp.match(string)
20
- group = Group.new(matches, string)
21
-
22
- expect(group.children[0].value).to eq('5')
23
- expect(group.children[1].value).to eq('10,20,30')
24
- expect(group.children[1].children[0].value).to eq('10')
25
- expect(group.children[1].children[1].value).to eq('20')
26
- expect(group.children[1].children[2].value).to eq('30')
27
- expect(group.children[2].value).to eq('40,50,60')
28
- expect(group.children[2].children[0].value).to eq('40')
29
- expect(group.children[2].children[1].value).to eq('50')
30
- expect(group.children[2].children[2].value).to eq('60')
31
- end
32
- end
33
- end
34
- end