cucumber-expressions 1.0.1 → 1.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
  SHA1:
3
- metadata.gz: f49e54c1b2b0772aaa088ae5d7d52c49e2b45732
4
- data.tar.gz: 5d9b537bfff91259546e6803b4a8b2b5f6af216e
3
+ metadata.gz: 24c2a1d775d8a7fafbdf9cca5074618579152749
4
+ data.tar.gz: d34c1ef714a341bbac1bd33713bd47c20fcb17be
5
5
  SHA512:
6
- metadata.gz: d1078ba24b2b7608a1e5184804ccbc7addf7eea1999f1caaba16db09d6a141c7098b045953aba2a508e94822a8857e44627454916ccb1e1fa1c06bafb52039e9
7
- data.tar.gz: a5bdc4982ee162f674ff3a2f4e5be43e67c45c12e8e9e7ccb67d47de9ed70282b1ccd61d12d49d3ba8d852b713e10fe62b09cd56af8d9a1294efea77edb68e62
6
+ metadata.gz: 840e2d44209c537e03fdbc27690cbe42093e27875a9377e9817dcddded07cf7418e3ce08cb2d6e8572226aec2b6069d7c3ac70ed50c3504c283686febf3038a2
7
+ data.tar.gz: 7fb30fab887f84735e7119697831da178cc6bed9f9728434acc21497fc210a0210e0fabda2fe679c2e92fd986403d1dea4451554b5a0217172abac65e107f789
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Cucumber Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Makefile CHANGED
@@ -1,8 +1,11 @@
1
- LICENSE: ../../LICENSE
2
- cp $< $@
1
+ .PHONY: build
2
+ build:
3
+ bundle install
4
+ bundle exec rake
3
5
 
4
6
  .PHONY: release
5
7
  release:
8
+ bundle install
6
9
  bundle exec rake build release:guard_clean release:rubygem_push
7
10
  version=$$(cat *.gemspec | grep -m 1 ".version *= *" | sed "s/.*= *'\([^']*\)'.*/\1/"); \
8
11
  git tag --annotate v$$version --message "Release $$version"
@@ -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 = '1.0.1'
4
+ s.version = '1.0.2'
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}"
@@ -13,3 +13,7 @@ I have 22 cukes in my belly now
13
13
  /I have (-?\d+) cukes? in my (.*) now/
14
14
  I have 1 cuke in my belly now
15
15
  [1,"belly"]
16
+ ---
17
+ /^Something( with an optional argument)?$/
18
+ Something
19
+ [null]
@@ -9,6 +9,7 @@ module Cucumber
9
9
  end
10
10
 
11
11
  def generate_expression(text, typed)
12
+ argumentNames = []
12
13
  transform_matchers = create_transform_matchers(text)
13
14
  transforms = []
14
15
 
@@ -26,12 +27,14 @@ module Cucumber
26
27
  end
27
28
 
28
29
  if matching_transform_matchers.any?
30
+ argumentName = "arg#{arg_counter += 1}"
31
+ argumentNames.push(argumentName)
29
32
  matching_transform_matchers = matching_transform_matchers.sort
30
33
  best_transform_matcher = matching_transform_matchers[0]
31
34
  transforms.push(best_transform_matcher.transform)
32
35
 
33
36
  expression += text.slice(pos...best_transform_matcher.start)
34
- expression += "{arg#{arg_counter += 1}"
37
+ expression += "{#{argumentName}"
35
38
 
36
39
  if typed
37
40
  expression += ":#{best_transform_matcher.transform.type_name}"
@@ -48,7 +51,7 @@ module Cucumber
48
51
  end
49
52
 
50
53
  expression += text.slice(pos..-1)
51
- GeneratedExpression.new(expression, transforms)
54
+ GeneratedExpression.new(expression, argumentNames, transforms)
52
55
  end
53
56
 
54
57
  private
@@ -1,10 +1,10 @@
1
1
  module Cucumber
2
2
  module CucumberExpressions
3
3
  class GeneratedExpression
4
- attr_reader :source, :transforms
4
+ attr_reader :source, :argumentNames, :transforms
5
5
 
6
- def initialize(source, transforms)
7
- @source, @transforms = source, transforms
6
+ def initialize(source, argumentNames, transforms)
7
+ @source, @argumentNames, @transforms = source, argumentNames, transforms
8
8
  end
9
9
  end
10
10
  end
@@ -20,6 +20,7 @@ module Cucumber
20
20
  undefined_step_text = "I have 2 cucumbers and 1.5 tomato"
21
21
  generated_expression = generator.generate_expression(undefined_step_text, true)
22
22
  expect(generated_expression.source).to eq("I have {arg1:int} cucumbers and {arg2:float} tomato")
23
+ expect(generated_expression.argumentNames[0]).to eq("arg1")
23
24
  expect(generated_expression.transforms[1].type).to eq(Float)
24
25
  ### [generate-expression]
25
26
  end
@@ -32,25 +32,25 @@ module Cucumber
32
32
  end
33
33
 
34
34
  describe CucumberExpression do
35
- it "converts arguments with expression type" do
35
+ it "transforms arguments with expression type" do
36
36
  expression = CucumberExpression.new("I have a {color:color} ball", [], @transform_lookup)
37
37
  transformed_argument_value = expression.match("I have a red ball")[0].transformed_value
38
38
  expect( transformed_argument_value ).to eq(Color.new('red'))
39
39
  end
40
40
 
41
- it "converts arguments with explicit type" do
41
+ it "transforms arguments with explicit type" do
42
42
  expression = CucumberExpression.new("I have a {color} ball", [Color], @transform_lookup)
43
43
  transformed_argument_value = expression.match("I have a red ball")[0].transformed_value
44
44
  expect( transformed_argument_value ).to eq(Color.new('red'))
45
45
  end
46
46
 
47
- it "converts arguments using argument name as type" do
47
+ it "transforms arguments using argument name as type" do
48
48
  expression = CucumberExpression.new("I have a {color} ball", [], @transform_lookup)
49
49
  transformed_argument_value = expression.match("I have a red ball")[0].transformed_value
50
50
  expect( transformed_argument_value ).to eq(Color.new('red'))
51
51
  end
52
52
 
53
- it "converts arguments with explicit type using constructor directly" do
53
+ it "transforms arguments with explicit type using constructor directly" do
54
54
  expression = CucumberExpression.new("I have a {color} ball", [Color], TransformLookup.new)
55
55
  transformed_argument_value = expression.match("I have a red ball")[0].transformed_value
56
56
  expect( transformed_argument_value ).to eq(Color.new('red'))
@@ -58,19 +58,19 @@ module Cucumber
58
58
  end
59
59
 
60
60
  describe RegularExpression do
61
- it "converts arguments with expression type" do
61
+ it "transforms arguments with expression type" do
62
62
  expression = RegularExpression.new(/I have a (red|blue|yellow) ball/, [], @transform_lookup)
63
63
  transformed_argument_value = expression.match("I have a red ball")[0].transformed_value
64
64
  expect( transformed_argument_value ).to eq(Color.new('red'))
65
65
  end
66
66
 
67
- it "converts arguments with explicit type" do
67
+ it "transforms arguments with explicit type" do
68
68
  expression = RegularExpression.new(/I have a (red|blue|yellow) ball/, ['color'], @transform_lookup)
69
69
  transformed_argument_value = expression.match("I have a red ball")[0].transformed_value
70
70
  expect( transformed_argument_value ).to eq(Color.new('red'))
71
71
  end
72
72
 
73
- it "converts arguments with explicit type using constructor directly" do
73
+ it "transforms arguments with explicit type using constructor directly" do
74
74
  expression = RegularExpression.new(/I have a (red|blue|yellow) ball/, [Color], TransformLookup.new)
75
75
  transformed_argument_value = expression.match("I have a red ball")[0].transformed_value
76
76
  expect( transformed_argument_value ).to eq(Color.new('red'))
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: 1.0.1
4
+ version: 1.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: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,7 @@ files:
89
89
  - ".rspec"
90
90
  - ".travis.yml"
91
91
  - Gemfile
92
+ - LICENSE
92
93
  - Makefile
93
94
  - README.md
94
95
  - Rakefile
@@ -132,10 +133,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
133
  version: '0'
133
134
  requirements: []
134
135
  rubyforge_project:
135
- rubygems_version: 2.5.1
136
+ rubygems_version: 2.5.2
136
137
  signing_key:
137
138
  specification_version: 4
138
- summary: cucumber-expressions-1.0.1
139
+ summary: cucumber-expressions-1.0.2
139
140
  test_files:
140
141
  - spec/capture_warnings.rb
141
142
  - spec/coverage.rb