turnip 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/turnip/placeholder.rb +11 -2
- data/lib/turnip/version.rb +1 -1
- data/spec/placeholder_spec.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4688d31baee09b9a1620f80d29a619ac86d73db9
|
4
|
+
data.tar.gz: 6c2ca9e0469398260c5f558bfb4c0a43f24a752b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da9af90c2aa18ea9bdb22b4854fd60e64cb4652b2c247cf1701afcf2ebce10d924e96ca8bba1168d5320205e8a15d74acbf5ca071f33232968435b84254be249
|
7
|
+
data.tar.gz: 139d1bd5f7af49ca90545ec0a31c216dcdd37bfd264b0cb74a2d016713c49cf9634494c2e75177bc1a33dcdb87e02d2dd9cf3b9072ade20a61643361028944aa
|
data/lib/turnip/placeholder.rb
CHANGED
@@ -64,11 +64,20 @@ module Turnip
|
|
64
64
|
private
|
65
65
|
|
66
66
|
def find_match(value)
|
67
|
-
|
67
|
+
@matches.each do |m|
|
68
68
|
result = value.scan(m.regexp)
|
69
69
|
return m, result.flatten unless result.empty?
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
|
+
#
|
73
|
+
# value is one of the following:
|
74
|
+
#
|
75
|
+
# %{Jhon Doe}
|
76
|
+
# %{"Jhon Doe"}
|
77
|
+
# %{'Jhon Doe'}
|
78
|
+
#
|
79
|
+
# In any case, it passed to the step block in the state without quotes
|
80
|
+
return @default, value.sub(/^(["'])([^\1]*)\1$/, '\2')
|
72
81
|
end
|
73
82
|
|
74
83
|
def placeholder_matches
|
data/lib/turnip/version.rb
CHANGED
data/spec/placeholder_spec.rb
CHANGED
@@ -94,6 +94,21 @@ describe Turnip::Placeholder do
|
|
94
94
|
expect(placeholder.apply('monkey')).to eq('kn|EY')
|
95
95
|
expect(placeholder.apply('bar')).to eq('bar')
|
96
96
|
end
|
97
|
+
|
98
|
+
it 'extracts captures by default placeholder and passes to the block' do
|
99
|
+
placeholder = described_class.new(:test) do
|
100
|
+
default do |v|
|
101
|
+
v
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
expect(placeholder.apply('John Doe')).to eq('John Doe')
|
106
|
+
expect(placeholder.apply('"John Doe"')).to eq('John Doe')
|
107
|
+
expect(placeholder.apply('\'John Doe\'')).to eq('John Doe')
|
108
|
+
|
109
|
+
expect(placeholder.apply('John \n Doe')).to eq('John \n Doe')
|
110
|
+
expect(placeholder.apply('"John \n Doe"')).to eq('John \n Doe')
|
111
|
+
end
|
97
112
|
end
|
98
113
|
|
99
114
|
describe '#regexp' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turnip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project: turnip
|
158
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.5.1
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: Gherkin extension for RSpec
|