cql 0.2.1 → 0.3.0
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 +15 -0
- data/lib/cql.rb +71 -63
- data/lib/dsl.rb +110 -110
- data/lib/feature_filters.rb +88 -72
- data/lib/map_reduce.rb +104 -40
- data/lib/sso_filters.rb +81 -72
- data/spec/filter_feature_dsl_spec.rb +284 -486
- data/spec/filter_sso_spec.rb +161 -288
- data/spec/line_count_filterable_specs.rb +73 -0
- data/spec/line_filterable_specs.rb +40 -0
- data/spec/map_reduce_spec.rb +132 -132
- data/spec/multiple_queries_spec.rb +27 -0
- data/spec/name_filterable_specs.rb +40 -0
- data/spec/select_feature_dsl_spec.rb +191 -50
- data/spec/select_scen_outline_dsl_spec.rb +323 -126
- data/spec/select_scenario_dsl_spec.rb +197 -73
- data/spec/spec_helper.rb +27 -0
- data/spec/tag_filterable_specs.rb +106 -0
- metadata +54 -37
- data/spec/unit_spec.rb +0 -22
@@ -1,126 +1,323 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
6
|
-
it 'should
|
7
|
-
gs = CQL::Repository.new
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
it 'should
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
result.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
result.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
result
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "select" do
|
4
|
+
describe 'from scenario_outlines' do
|
5
|
+
|
6
|
+
it 'should return tags from scenario outlines' do
|
7
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
|
8
|
+
|
9
|
+
result = gs.query do
|
10
|
+
select tags
|
11
|
+
from scenario_outlines
|
12
|
+
end
|
13
|
+
|
14
|
+
expect(result).to eq([{"tags" => [{"name" => "@two", "line" => 3}]},
|
15
|
+
{"tags" => [{"name" => "@one", "line" => 13}]},
|
16
|
+
{"tags" => nil},
|
17
|
+
{"tags" => [{"name" => "@two", "line" => 24}]},
|
18
|
+
{"tags" => [{"name" => "@one", "line" => 30}]},
|
19
|
+
{"tags" => [{"name" => "@two", "line" => 3}, {"name" => "@four", "line" => 3}]},
|
20
|
+
{"tags" => [{"name" => "@one", "line" => 13}, {"name" => "@five", "line" => 13}]},
|
21
|
+
{"tags" => nil},
|
22
|
+
{"tags" => [{"name" => "@two", "line" => 24}]},
|
23
|
+
{"tags" => [{"name" => "@one", "line" => 30}]}])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should return descriptions from scenario outlines' do
|
27
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
|
28
|
+
|
29
|
+
result = gs.query do
|
30
|
+
select description
|
31
|
+
from scenario_outlines
|
32
|
+
end
|
33
|
+
|
34
|
+
expect(result).to eq([{"description" => ""}, {"description" => "Outline description."}])
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return lines from scenario outlines' do
|
38
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
39
|
+
|
40
|
+
result = gs.query do
|
41
|
+
select line
|
42
|
+
from scenario_outlines
|
43
|
+
end
|
44
|
+
|
45
|
+
expect(result).to eq([{"line" => 3}])
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should return names from scenario outlines' do
|
49
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
50
|
+
|
51
|
+
result = gs.query do
|
52
|
+
select name
|
53
|
+
from scenario_outlines
|
54
|
+
end
|
55
|
+
|
56
|
+
expect(result).to eq([{"name" => "An Outline"}])
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return types from scenario outlines' do
|
60
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
61
|
+
|
62
|
+
result = gs.query do
|
63
|
+
select type
|
64
|
+
from scenario_outlines
|
65
|
+
end
|
66
|
+
|
67
|
+
expect(result).to eq([{"type" => "scenario_outline"}])
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should return step lines from scenario outlines' do
|
71
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
72
|
+
|
73
|
+
result = gs.query do
|
74
|
+
select step_lines
|
75
|
+
from scenario_outlines
|
76
|
+
end
|
77
|
+
|
78
|
+
expect(result).to eq([{"step_lines" => ["Given something happend", "Then I expect something else"]}])
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should return ids from scenario outlines' do
|
82
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
83
|
+
|
84
|
+
result = gs.query do
|
85
|
+
select id
|
86
|
+
from scenario_outlines
|
87
|
+
end
|
88
|
+
|
89
|
+
expect(result).to eq([{"id" => "test-feature;an-outline"}])
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should return steps from scenario outlines' do
|
93
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
94
|
+
|
95
|
+
result = gs.query do
|
96
|
+
select steps
|
97
|
+
from scenario_outlines
|
98
|
+
end
|
99
|
+
|
100
|
+
expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}]}])
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
it 'should return multiple things from scenario outlines' do
|
105
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
|
106
|
+
|
107
|
+
result = gs.query do
|
108
|
+
select name, tags
|
109
|
+
from scenario_outlines
|
110
|
+
end
|
111
|
+
|
112
|
+
expect(result).to eq([{"name" => "An Outline", "tags" => nil},
|
113
|
+
{"name" => "An Outline with everything", "tags" => [{"name" => "@outline_tag", "line" => 21}]}])
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should return things from multiple feature files' do
|
117
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
|
118
|
+
|
119
|
+
result = gr.query do
|
120
|
+
select name
|
121
|
+
from scenario_outlines
|
122
|
+
end
|
123
|
+
|
124
|
+
expect(result).to eq([{"name" => "Has a table"},
|
125
|
+
{"name" => "Next"},
|
126
|
+
{"name" => "Another"},
|
127
|
+
{"name" => "Blah"},
|
128
|
+
{"name" => "Another"},
|
129
|
+
{"name" => "Has a table hmmm"},
|
130
|
+
{"name" => "Next"},
|
131
|
+
{"name" => "Another"},
|
132
|
+
{"name" => "Blah blah"},
|
133
|
+
{"name" => "Another"}])
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should return multiple scenario outlines as a list of maps' do
|
137
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines")
|
138
|
+
|
139
|
+
result = gr.query do
|
140
|
+
select name
|
141
|
+
from scenario_outlines
|
142
|
+
end
|
143
|
+
|
144
|
+
expect(result).to be_an_instance_of(Array)
|
145
|
+
|
146
|
+
result.each do |item|
|
147
|
+
expect(item).to be_an_instance_of(Hash)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should return the examples from scenario outlines" do
|
152
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
153
|
+
result = gr.query do
|
154
|
+
select examples
|
155
|
+
from scenario_outlines
|
156
|
+
end
|
157
|
+
|
158
|
+
expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "", "line" => 6,
|
159
|
+
"description" => "", "id" => "test-feature;an-outline;",
|
160
|
+
"rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;;1"},
|
161
|
+
{"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;;2"},
|
162
|
+
{"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;;3"},
|
163
|
+
{"cells" => ["3", "c"], "line" => 10, "id" => "test-feature;an-outline;;4"},
|
164
|
+
{"cells" => ["4", "d"], "line" => 11, "id" => "test-feature;an-outline;;5"}]}]}])
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should return multiple examples used for a single scenario outline" do
|
168
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
|
169
|
+
result = gr.query do
|
170
|
+
select examples
|
171
|
+
from scenario_outlines
|
172
|
+
end
|
173
|
+
|
174
|
+
expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 6, "description" => "", "id" => "test-feature;an-outline;one",
|
175
|
+
"rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;one;1"},
|
176
|
+
{"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;one;2"},
|
177
|
+
{"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;one;3"}]},
|
178
|
+
{"keyword" => "Examples", "name" => "Two", "line" => 11, "description" => "", "id" => "test-feature;an-outline;two",
|
179
|
+
"rows" => [{"cells" => ["var_a", "var_b"], "line" => 12, "id" => "test-feature;an-outline;two;1"},
|
180
|
+
{"cells" => ["1", "a"], "line" => 13, "id" => "test-feature;an-outline;two;2"},
|
181
|
+
{"cells" => ["2", "b"], "line" => 14, "id" => "test-feature;an-outline;two;3"}]}]},
|
182
|
+
{"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 31, "description" => "This is example One.", "id" => "test-feature;an-outline-with-everything;one",
|
183
|
+
"rows" => [{"cells" => ["var_a", "var_b"], "line" => 34, "id" => "test-feature;an-outline-with-everything;one;1"},
|
184
|
+
{"cells" => ["1", "a"], "line" => 35, "id" => "test-feature;an-outline-with-everything;one;2"},
|
185
|
+
{"cells" => ["2", "b"], "line" => 36, "id" => "test-feature;an-outline-with-everything;one;3"}]},
|
186
|
+
{"keyword" => "Examples", "name" => "Two", "line" => 39, "description" => "", "tags" => [{"name" => "@example_tag", "line" => 38}], "id" => "test-feature;an-outline-with-everything;two",
|
187
|
+
"rows" => [{"cells" => ["var_a", "var_b"], "line" => 40, "id" => "test-feature;an-outline-with-everything;two;1"},
|
188
|
+
{"cells" => ["1", "a"], "line" => 41, "id" => "test-feature;an-outline-with-everything;two;2"},
|
189
|
+
{"cells" => ["2", "b"], "line" => 42, "id" => "test-feature;an-outline-with-everything;two;3"}]}]}])
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
it "should return all, complete, everything from scenario_outlines" do
|
194
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
|
195
|
+
|
196
|
+
|
197
|
+
expected = [{"all" => {"keyword" => "Scenario Outline",
|
198
|
+
"name" => "An Outline",
|
199
|
+
"line" => 3,
|
200
|
+
"description" => "",
|
201
|
+
"id" => "test-feature;an-outline",
|
202
|
+
"type" => "scenario_outline",
|
203
|
+
"steps" => [{"keyword" => "Given ",
|
204
|
+
"name" => "something happend",
|
205
|
+
"line" => 4},
|
206
|
+
{"keyword" => "Then ",
|
207
|
+
"name" => "I expect something else",
|
208
|
+
"line" => 5}],
|
209
|
+
"examples" => [{"keyword" => "Examples",
|
210
|
+
"name" => "One",
|
211
|
+
"line" => 6,
|
212
|
+
"description" => "",
|
213
|
+
"id" => "test-feature;an-outline;one",
|
214
|
+
"rows" => [{"cells" => ["var_a", "var_b"],
|
215
|
+
"line" => 7,
|
216
|
+
"id" => "test-feature;an-outline;one;1"},
|
217
|
+
{"cells" => ["1", "a"],
|
218
|
+
"line" => 8,
|
219
|
+
"id" => "test-feature;an-outline;one;2"},
|
220
|
+
{"cells" => ["2", "b"],
|
221
|
+
"line" => 9,
|
222
|
+
"id" => "test-feature;an-outline;one;3"}]},
|
223
|
+
{"keyword" => "Examples",
|
224
|
+
"name" => "Two",
|
225
|
+
"line" => 11,
|
226
|
+
"description" => "",
|
227
|
+
"id" => "test-feature;an-outline;two",
|
228
|
+
"rows" => [{"cells" => ["var_a", "var_b"],
|
229
|
+
"line" => 12,
|
230
|
+
"id" => "test-feature;an-outline;two;1"},
|
231
|
+
{"cells" => ["1", "a"],
|
232
|
+
"line" => 13,
|
233
|
+
"id" => "test-feature;an-outline;two;2"},
|
234
|
+
{"cells" => ["2", "b"],
|
235
|
+
"line" => 14,
|
236
|
+
"id" => "test-feature;an-outline;two;3"}]}]}},
|
237
|
+
{"all" => {"keyword" => "Scenario Outline",
|
238
|
+
"name" => "An Outline with everything",
|
239
|
+
"line" => 22,
|
240
|
+
"description" => "\nOutline description.",
|
241
|
+
"tags" => [{"name" => "@outline_tag",
|
242
|
+
"line" => 21}],
|
243
|
+
"id" => "test-feature;an-outline-with-everything",
|
244
|
+
"type" => "scenario_outline",
|
245
|
+
"steps" => [{"keyword" => "Given ",
|
246
|
+
"name" => "something happend",
|
247
|
+
"line" => 26,
|
248
|
+
"rows" => [{"cells" => ["a", "a"],
|
249
|
+
"line" => 27},
|
250
|
+
{"cells" => ["s", "a"],
|
251
|
+
"line" => 28},
|
252
|
+
{"cells" => ["s", "s"],
|
253
|
+
"line" => 29}]},
|
254
|
+
{"keyword" => "Then ",
|
255
|
+
"name" => "I expect something else",
|
256
|
+
"line" => 30}],
|
257
|
+
"examples" => [{"keyword" => "Examples",
|
258
|
+
"name" => "One",
|
259
|
+
"line" => 31,
|
260
|
+
"description" => "This is example One.",
|
261
|
+
"id" => "test-feature;an-outline-with-everything;one",
|
262
|
+
"rows" => [{"cells" => ["var_a", "var_b"],
|
263
|
+
"line" => 34,
|
264
|
+
"id" => "test-feature;an-outline-with-everything;one;1"},
|
265
|
+
{"cells" => ["1", "a"],
|
266
|
+
"line" => 35,
|
267
|
+
"id" => "test-feature;an-outline-with-everything;one;2"},
|
268
|
+
{"cells" => ["2", "b"],
|
269
|
+
"line" => 36,
|
270
|
+
"id" => "test-feature;an-outline-with-everything;one;3"}]},
|
271
|
+
{"keyword" => "Examples",
|
272
|
+
"name" => "Two",
|
273
|
+
"line" => 39,
|
274
|
+
"description" => "",
|
275
|
+
"tags" => [{"name" => "@example_tag",
|
276
|
+
"line" => 38}],
|
277
|
+
"id" => "test-feature;an-outline-with-everything;two",
|
278
|
+
"rows" => [{"cells" => ["var_a", "var_b"],
|
279
|
+
"line" => 40,
|
280
|
+
"id" => "test-feature;an-outline-with-everything;two;1"},
|
281
|
+
{"cells" => ["1", "a"],
|
282
|
+
"line" => 41,
|
283
|
+
"id" => "test-feature;an-outline-with-everything;two;2"},
|
284
|
+
{"cells" => ["2", "b"],
|
285
|
+
"line" => 42,
|
286
|
+
"id" => "test-feature;an-outline-with-everything;two;3"}]}]}}]
|
287
|
+
|
288
|
+
result = gr.query do
|
289
|
+
select all
|
290
|
+
from scenario_outlines
|
291
|
+
end
|
292
|
+
expect(result).to eq(expected)
|
293
|
+
|
294
|
+
result = gr.query do
|
295
|
+
select complete
|
296
|
+
from scenario_outlines
|
297
|
+
end
|
298
|
+
expect(result).to eq(expected)
|
299
|
+
|
300
|
+
result = gr.query do
|
301
|
+
select everything
|
302
|
+
from scenario_outlines
|
303
|
+
end
|
304
|
+
expect(result).to eq(expected)
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'should return scenario outlines name and line numbers as a map' do
|
308
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
|
309
|
+
result = gs.query do
|
310
|
+
select name, line, type, step_lines, id, steps
|
311
|
+
from scenario_outlines
|
312
|
+
end
|
313
|
+
|
314
|
+
expect(result).to eq([{'name' => "An Outline",
|
315
|
+
'line' => 3,
|
316
|
+
'id' => 'test-feature;an-outline',
|
317
|
+
'type' => 'scenario_outline',
|
318
|
+
"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}],
|
319
|
+
"step_lines" => ["Given something happend", "Then I expect something else"]}])
|
320
|
+
end
|
321
|
+
|
322
|
+
end
|
323
|
+
end
|
@@ -1,73 +1,197 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
result =
|
10
|
-
select
|
11
|
-
from scenarios
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
result.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "select" do
|
4
|
+
describe 'from scenarios' do
|
5
|
+
|
6
|
+
it 'should return tags from scenarios' do
|
7
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tags2")
|
8
|
+
|
9
|
+
result = gs.query do
|
10
|
+
select tags
|
11
|
+
from scenarios
|
12
|
+
end
|
13
|
+
|
14
|
+
expect(result).to eq([{"tags" => [{"name" => "@two", "line" => 3}]},
|
15
|
+
{"tags" => [{"name" => "@one", "line" => 11}]},
|
16
|
+
{"tags" => nil},
|
17
|
+
{"tags" => [{"name" => "@two", "line" => 18}]},
|
18
|
+
{"tags" => [{"name" => "@one", "line" => 22}]},
|
19
|
+
{"tags" => [{"name" => "@two", "line" => 3}, {"name" => "@four", "line" => 3}]},
|
20
|
+
{"tags" => [{"name" => "@one", "line" => 11}, {"name" => "@five", "line" => 11}]},
|
21
|
+
{"tags" => nil},
|
22
|
+
{"tags" => [{"name" => "@two", "line" => 18}]},
|
23
|
+
{"tags" => [{"name" => "@one", "line" => 22}]}])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should return descriptions from scenarios' do
|
27
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/table")
|
28
|
+
|
29
|
+
result = gs.query do
|
30
|
+
select description
|
31
|
+
from scenarios
|
32
|
+
end
|
33
|
+
|
34
|
+
expect(result).to eq([{"description" => "Scenario description."}])
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return lines from scenarios' do
|
38
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
39
|
+
|
40
|
+
result = gr.query do
|
41
|
+
select line
|
42
|
+
from scenarios
|
43
|
+
end
|
44
|
+
|
45
|
+
expect(result).to eq([{"line" => 6}, {"line" => 11}, {"line" => 16}, {"line" => 21}])
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should return names from scenarios' do
|
49
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
50
|
+
|
51
|
+
result = gr.query do
|
52
|
+
select name
|
53
|
+
from scenarios
|
54
|
+
end
|
55
|
+
|
56
|
+
expect(result).to eq([{"name" => "Testing the slurping"}, {"name" => "Testing again"},
|
57
|
+
{"name" => "Testing yet again"}, {"name" => "Testing yet again part 2"}])
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should return types from scenarios' do
|
61
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
62
|
+
|
63
|
+
result = gs.query do
|
64
|
+
select type
|
65
|
+
from scenarios
|
66
|
+
end
|
67
|
+
|
68
|
+
expect(result).to eq([{"type" => "scenario"}, {"type" => "scenario"},
|
69
|
+
{"type" => "scenario"}, {"type" => "scenario"}])
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should return step lines from scenarios' do
|
73
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
74
|
+
|
75
|
+
result = gs.query do
|
76
|
+
select step_lines
|
77
|
+
from scenarios
|
78
|
+
end
|
79
|
+
|
80
|
+
expect(result).to eq([{"step_lines" => ["Given something happend", "Then I expect something else"]},
|
81
|
+
{"step_lines" => ["Given something happend", "Then I expect something else"]},
|
82
|
+
{"step_lines" => ["Given something happend", "Then I expect something else"]},
|
83
|
+
{"step_lines" => ["Given something happend", "Then I expect something else"]}])
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should return ids from scenarios' do
|
87
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
88
|
+
|
89
|
+
result = gs.query do
|
90
|
+
select id
|
91
|
+
from scenarios
|
92
|
+
end
|
93
|
+
|
94
|
+
expect(result).to eq([{"id" => "test3-feature;testing-the-slurping"},
|
95
|
+
{"id" => "test3-feature;testing-again"},
|
96
|
+
{"id" => "test3-feature;testing-yet-again"},
|
97
|
+
{"id" => "test3-feature;testing-yet-again-part-2"},])
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should return steps from scenarios' do
|
101
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
102
|
+
|
103
|
+
result = gs.query do
|
104
|
+
select steps
|
105
|
+
from scenarios
|
106
|
+
end
|
107
|
+
|
108
|
+
expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 7}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 8}]},
|
109
|
+
{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 12}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 13}]},
|
110
|
+
{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 17}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 18}]},
|
111
|
+
{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 22}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 23}]}])
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return multiple things from scenarios' do
|
115
|
+
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
116
|
+
|
117
|
+
result = gs.query do
|
118
|
+
select name, tags
|
119
|
+
from scenarios
|
120
|
+
end
|
121
|
+
|
122
|
+
expect(result).to eq([{"name" => "Testing the slurping", "tags" => [{"name" => "@one", "line" => 5}]},
|
123
|
+
{"name" => "Testing again", "tags" => [{"name" => "@two", "line" => 10}]},
|
124
|
+
{"name" => "Testing yet again", "tags" => [{"name" => "@one", "line" => 15}]},
|
125
|
+
{"name" => "Testing yet again part 2", "tags" => [{"name" => "@one", "line" => 20}, {"name" => "@two", "line" => 20}]}])
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should return things from multiple feature files' do
|
129
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
|
130
|
+
|
131
|
+
result = gr.query do
|
132
|
+
select name
|
133
|
+
from scenarios
|
134
|
+
end
|
135
|
+
|
136
|
+
expect(result).to eq([{"name" => "Has a table"}, {"name" => "Testing the slurping 1"},
|
137
|
+
{"name" => "Testing the slurping not to be found"}, {"name" => "Testing the slurping 2"},
|
138
|
+
{"name" => "Testing the slurping 3"}, {"name" => "Testing again"},
|
139
|
+
{"name" => "Testing yet again"}, {"name" => "Testing yet again part 2"}])
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should get multiple scenarios as a list of maps' do
|
143
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
|
144
|
+
result = gr.query do
|
145
|
+
select line, name
|
146
|
+
from scenarios
|
147
|
+
end
|
148
|
+
|
149
|
+
expect(result).to eq([{'line' => 6, 'name' => "Testing the slurping"}, {'line' => 11, 'name' => "Testing again"},
|
150
|
+
{'line' => 16, 'name' => "Testing yet again"}, {'line' => 21, 'name' => "Testing yet again part 2"}])
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should return all, complete, everything from scenarios" do
|
154
|
+
gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/table")
|
155
|
+
|
156
|
+
expected = [{"all" => {"keyword" => "Scenario",
|
157
|
+
"name" => "Has a table",
|
158
|
+
"line" => 4,
|
159
|
+
"description" => "Scenario description.",
|
160
|
+
"tags" => [{"name" => "@scenario_tag",
|
161
|
+
"line" => 3}],
|
162
|
+
"id" => "simple;has-a-table",
|
163
|
+
"type" => "scenario",
|
164
|
+
"steps" => [{"keyword" => "Given ",
|
165
|
+
"name" => "Something",
|
166
|
+
"line" => 7,
|
167
|
+
"rows" => [{"cells" => ["a", "a"],
|
168
|
+
"line" => 8},
|
169
|
+
{"cells" => ["s", "a"],
|
170
|
+
"line" => 9},
|
171
|
+
{"cells" => ["s", "s"],
|
172
|
+
"line" => 10}]},
|
173
|
+
{"keyword" => "Then ",
|
174
|
+
"name" => "something else",
|
175
|
+
"line" => 11}]}}]
|
176
|
+
|
177
|
+
result = gr.query do
|
178
|
+
select all
|
179
|
+
from scenarios
|
180
|
+
end
|
181
|
+
expect(result).to eq(expected)
|
182
|
+
|
183
|
+
result = gr.query do
|
184
|
+
select complete
|
185
|
+
from scenarios
|
186
|
+
end
|
187
|
+
expect(result).to eq(expected)
|
188
|
+
|
189
|
+
result = gr.query do
|
190
|
+
select everything
|
191
|
+
from scenarios
|
192
|
+
end
|
193
|
+
expect(result).to eq(expected)
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
end
|