turnip 2.1.1 → 3.0.0.pre.beta.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 +4 -4
- data/lib/turnip/builder.rb +66 -69
- data/lib/turnip/version.rb +1 -1
- data/turnip.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8425f714759628ba119de6a3d1c4f8d7b8822c1
|
4
|
+
data.tar.gz: 342a721605fd9f29e0812962c1abbd7f98d5eaa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83c07693eb5d083086cbd570532566e3bbcdbce60b5114f57091612b2d4dc1ec25b46794d9c5603eee547a4167eaad555d6cc9969a8bac2e53941455b51ad649
|
7
|
+
data.tar.gz: 2116eac308a84e0d4119f26fef894dafd9fcfbf11d34671297bf50920268e8b4a2102da61aeae8b43396a1c4a1fad0f16847b23aa45ccba2575367461059ba64
|
data/lib/turnip/builder.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
require "gherkin"
|
1
|
+
require "gherkin/parser"
|
2
|
+
require "gherkin/token_scanner"
|
2
3
|
|
3
4
|
module Turnip
|
4
5
|
class Builder
|
5
6
|
module Tags
|
6
7
|
def tags
|
7
|
-
@raw
|
8
|
+
@raw[:tags].map { |tag| tag[:name].sub(/^@/, '') }
|
8
9
|
end
|
9
10
|
|
10
11
|
def tags_hash
|
@@ -18,13 +19,30 @@ module Turnip
|
|
18
19
|
|
19
20
|
module Name
|
20
21
|
def name
|
21
|
-
@raw
|
22
|
+
@raw[:name]
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
module Line
|
26
27
|
def line
|
27
|
-
@raw
|
28
|
+
@raw[:location][:line]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Steps
|
33
|
+
def steps
|
34
|
+
@steps ||= @raw[:steps].map do |step|
|
35
|
+
extra_args = []
|
36
|
+
if (arg = step[:argument])
|
37
|
+
if arg[:type] == :DataTable
|
38
|
+
table = Turnip::Table.new(arg[:rows].map {|r| r[:cells].map {|c| c[:value]}})
|
39
|
+
extra_args.push(table)
|
40
|
+
else
|
41
|
+
extra_args.push arg[:content]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
Step.new(step[:text], extra_args, step[:location][:line], step[:keyword])
|
45
|
+
end
|
28
46
|
end
|
29
47
|
end
|
30
48
|
|
@@ -48,10 +66,10 @@ module Turnip
|
|
48
66
|
end
|
49
67
|
|
50
68
|
class Background
|
51
|
-
|
69
|
+
include Steps
|
70
|
+
|
52
71
|
def initialize(raw)
|
53
72
|
@raw = raw
|
54
|
-
@steps = []
|
55
73
|
end
|
56
74
|
end
|
57
75
|
|
@@ -59,47 +77,48 @@ module Turnip
|
|
59
77
|
include Tags
|
60
78
|
include Name
|
61
79
|
include Line
|
80
|
+
include Steps
|
62
81
|
|
63
|
-
|
82
|
+
attr_writer :steps
|
64
83
|
|
65
84
|
def initialize(raw)
|
66
85
|
@raw = raw
|
67
|
-
@steps = []
|
68
86
|
end
|
69
87
|
end
|
70
88
|
|
71
89
|
class ScenarioOutline
|
72
90
|
include Tags
|
73
91
|
include Name
|
74
|
-
|
75
|
-
attr_reader :steps
|
92
|
+
include Steps
|
76
93
|
|
77
94
|
def initialize(raw)
|
78
95
|
@raw = raw
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
Turnip::Table
|
95
|
-
|
96
|
-
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_scenarios
|
99
|
+
return [] unless @raw[:examples]
|
100
|
+
@raw[:examples].map { |example|
|
101
|
+
headers = example[:tableHeader][:cells].map {|c| c[:value]}
|
102
|
+
rows = example[:tableBody].map {|r| r[:cells].map {|c| c[:value]}}
|
103
|
+
rows.map do |row|
|
104
|
+
Scenario.new(@raw).tap do |scenario|
|
105
|
+
scenario.steps = steps.map do |step|
|
106
|
+
new_description = substitute(step.description, headers, row)
|
107
|
+
new_extra_args = step.extra_args.map do |ea|
|
108
|
+
case ea
|
109
|
+
when String
|
110
|
+
substitute(ea, headers, row)
|
111
|
+
when Turnip::Table
|
112
|
+
Turnip::Table.new(ea.map {|t_row| t_row.map {|t_col| substitute(t_col, headers, row) } })
|
113
|
+
else
|
114
|
+
ea
|
115
|
+
end
|
97
116
|
end
|
117
|
+
Step.new(new_description, new_extra_args, step.line, step.keyword)
|
98
118
|
end
|
99
|
-
Step.new(new_description, new_extra_args, step.line, step.keyword)
|
100
119
|
end
|
101
120
|
end
|
102
|
-
|
121
|
+
}.flatten
|
103
122
|
end
|
104
123
|
|
105
124
|
private
|
@@ -120,8 +139,9 @@ module Turnip
|
|
120
139
|
class << self
|
121
140
|
def build(feature_file)
|
122
141
|
Turnip::Builder.new.tap do |builder|
|
123
|
-
parser = Gherkin::Parser
|
124
|
-
parser.parse(File.read(feature_file)
|
142
|
+
parser = Gherkin::Parser.new
|
143
|
+
result = parser.parse(File.read(feature_file))
|
144
|
+
builder.build(result)
|
125
145
|
end
|
126
146
|
end
|
127
147
|
end
|
@@ -130,44 +150,21 @@ module Turnip
|
|
130
150
|
@features = []
|
131
151
|
end
|
132
152
|
|
133
|
-
def
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
def scenario_outline(outline)
|
149
|
-
@current_step_context = ScenarioOutline.new(outline)
|
150
|
-
end
|
151
|
-
|
152
|
-
def examples(examples)
|
153
|
-
@current_feature.scenarios.push(*@current_step_context.to_scenarios(examples))
|
154
|
-
end
|
155
|
-
|
156
|
-
def step(step)
|
157
|
-
extra_args = []
|
158
|
-
if step.doc_string
|
159
|
-
extra_args.push step.doc_string.value
|
160
|
-
elsif step.rows
|
161
|
-
table = Turnip::Table.new(step.rows.map(&:cells).map(&:to_a))
|
162
|
-
extra_args.push(table)
|
153
|
+
def build(attributes)
|
154
|
+
return unless attributes[:feature]
|
155
|
+
attr = attributes[:feature]
|
156
|
+
feature = Feature.new(attr)
|
157
|
+
attr[:children].each do |child|
|
158
|
+
case child[:type]
|
159
|
+
when :Background
|
160
|
+
feature.backgrounds << Background.new(child)
|
161
|
+
when :Scenario
|
162
|
+
feature.scenarios << Scenario.new(child)
|
163
|
+
else
|
164
|
+
feature.scenarios.push(*ScenarioOutline.new(child).to_scenarios)
|
165
|
+
end
|
163
166
|
end
|
164
|
-
@
|
165
|
-
end
|
166
|
-
|
167
|
-
def uri(*)
|
168
|
-
end
|
169
|
-
|
170
|
-
def eof
|
167
|
+
@features << feature
|
171
168
|
end
|
172
169
|
end
|
173
170
|
end
|
data/lib/turnip/version.rb
CHANGED
data/turnip.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_runtime_dependency "rspec", [">=3.0", "<4.0"]
|
22
|
-
s.add_runtime_dependency "gherkin", "~>
|
22
|
+
s.add_runtime_dependency "gherkin", "~> 4.0"
|
23
23
|
s.add_development_dependency "rake"
|
24
24
|
s.add_development_dependency "pry"
|
25
25
|
end
|
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:
|
4
|
+
version: 3.0.0.pre.beta.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-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '4.0'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '4.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,9 +150,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
|
-
- - "
|
153
|
+
- - ">"
|
154
154
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
155
|
+
version: 1.3.1
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project: turnip
|
158
158
|
rubygems_version: 2.5.1
|