cql 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,126 +1,323 @@
1
- require 'rspec'
2
- require File.dirname(__FILE__) + "/../lib/cql"
3
-
4
- describe "select" do
5
- describe "single value, single results" do
6
- it 'should get scenario outlines line number' do
7
- gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
8
- result = gs.query do
9
- select line
10
- from scenario_outlines
11
- end
12
- result.should == {"line"=>3}
13
- end
14
-
15
- it 'should get scenario outlines name' do
16
- gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
17
- result = gs.query do
18
- select name
19
- from scenario_outlines
20
- end
21
- result.should == {"name"=> "An Outline"}
22
- end
23
-
24
- it "should return the examples used" do
25
- gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
26
- result = gr.query do
27
- select examples
28
- from scenario_outlines
29
- end
30
- result.should == {"examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6,
31
- "description"=>"", "id"=>"test-feature;an-outline;",
32
- "rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"},
33
- {"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"},
34
- {"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"},
35
- {"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"},
36
- {"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]
37
- }]}
38
- end
39
-
40
- it "should return multiple examples used for a single scenario outline" do
41
- gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/multiple_examples"
42
- result = gr.query do
43
- select examples
44
- from scenario_outlines
45
- end
46
- result.should == {"examples"=>[{"keyword"=>"Examples", "name"=>"One", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;one",
47
- "rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;one;1"},
48
- {"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;one;2"},
49
- {"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;one;3"}]},
50
- {"keyword"=>"Examples", "name"=>"Two", "line"=>11, "description"=>"", "id"=>"test-feature;an-outline;two",
51
- "rows"=>[{"cells"=>["var_a", "var_b"], "line"=>12, "id"=>"test-feature;an-outline;two;1"},
52
- {"cells"=>["1", "a"], "line"=>13, "id"=>"test-feature;an-outline;two;2"},
53
- {"cells"=>["2", "b"], "line"=>14, "id"=>"test-feature;an-outline;two;3"}]}]}
54
- end
55
-
56
- end
57
-
58
- describe "single value, multiple results" do
59
- it 'should get scenario outlines as is when no select criteria given' do
60
- expected = {"all"=>{"keyword"=>"Scenario Outline",
61
- "name"=>"An Outline",
62
- "line"=>3, "description"=>"",
63
- "id"=>"test-feature;an-outline", "type"=>"scenario_outline",
64
- "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
65
- {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}],
66
- "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;",
67
- "rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"},
68
- {"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"},
69
- {"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"},
70
- {"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"},
71
- {"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]}]}}
72
-
73
- gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
74
- result = gs.query do
75
- select all
76
- from scenario_outlines
77
- end
78
- result.should == expected
79
-
80
- result = gs.query do
81
- select everything
82
- from scenario_outlines
83
- end
84
- result.should == expected
85
-
86
- result = gs.query do
87
- select complete
88
- from scenario_outlines
89
- end
90
- result.should == expected
91
- end
92
- end
93
-
94
- describe "select all" do
95
-
96
- end
97
-
98
- describe "special selectors" do
99
- it 'should get the full step line scenario outlines' do
100
- gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
101
- result = gs.query do
102
- select step_lines
103
- from scenario_outlines
104
- end
105
- result.should == {"step_lines"=> ["Given something happend", "Then I expect something else"]}
106
- end
107
- end
108
-
109
- describe "multiple values" do
110
- it 'should get scenario outlines name and line numbers as a map' do
111
- gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
112
- result = gs.query do
113
- select name, line, type, step_lines, id, steps
114
- from scenario_outlines
115
- end
116
- result.should == {'name'=>"An Outline",
117
- 'line'=>3,
118
- 'id'=>'test-feature;an-outline',
119
- 'type'=>'scenario_outline',
120
- "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}],
121
- "step_lines"=>["Given something happend", "Then I expect something else"]
122
- }
123
- end
124
-
125
- end
126
- end
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 'rspec'
2
- require File.dirname(__FILE__) + "/../lib/cql"
3
-
4
- describe "select" do
5
-
6
- describe "single value, multiple results" do
7
- it 'should get scenario line number' do
8
- gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
9
- result = gr.query do
10
- select line
11
- from scenarios
12
- end
13
- result.should == [{"line"=> 6}, {"line"=> 11}, {"line"=> 16}, {"line"=> 21}]
14
- end
15
-
16
- it 'should get scenario name' do
17
- gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
18
- result = gr.query do
19
- select name
20
- from scenarios
21
- end
22
- result.should == [{"name"=> "Testing the slurping"}, {"name"=> "Testing again"},
23
- {"name"=> "Testing yet again"}, {"name"=> "Testing yet again part 2"}]
24
- end
25
-
26
- it 'should get scenario name from multiple feature files' do
27
- gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
28
- result = gr.query do
29
- select name
30
- from scenarios
31
- end
32
- result.should == [{"name"=> "Has a table"}, {"name"=> "Testing the slurping 1"},
33
- {"name"=> "Testing the slurping not to be found"}, {"name"=> "Testing the slurping 2"},
34
- {"name"=> "Testing the slurping 3"}, {"name"=> "Testing again"},
35
- {"name"=> "Testing yet again"}, {"name"=> "Testing yet again part 2"}]
36
- end
37
- end
38
-
39
- describe "multiple values" do
40
- it 'should get multiple scenarios as a list of maps' do
41
- gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
42
- result = gr.query do
43
- select line, name
44
- from scenarios
45
- end
46
- result.should == [{'line'=>6, 'name'=>"Testing the slurping"}, {'line'=>11, 'name'=>"Testing again"},
47
- {'line'=>16, 'name'=>"Testing yet again"}, {'line'=>21, 'name'=>"Testing yet again part 2"}]
48
- end
49
-
50
- it "should select all" do
51
- gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/table"
52
- expected = {"all"=>{"keyword"=>"Scenario", "name"=>"Has a table", "line"=>3,
53
- "description"=>"", "id"=>"simple;has-a-table", "type"=>"scenario",
54
- "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4,
55
- "rows"=>[{"cells"=>["a", "a"], "line"=>5}, {"cells"=>["s", "a"], "line"=>6},
56
- {"cells"=>["s", "s"], "line"=>7}]},
57
- {"keyword"=>"Then ", "name"=>"something else", "line"=>8}]}}
58
-
59
- result = gr.query do
60
- select all
61
- from scenarios
62
- end
63
- result.should == expected
64
-
65
- result = gr.query do
66
- select complete
67
- from scenarios
68
- end
69
- result.should == expected
70
- end
71
-
72
- end
73
- end
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