cql 0.1.0 → 0.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dsl.rb +64 -0
- data/lib/map_reduce.rb +139 -0
- data/lib/repo.rb +34 -0
- data/spec/filter_feature_dsl_spec.rb +486 -0
- data/spec/filter_sso_spec.rb +279 -0
- data/spec/map_reduce_spec.rb +132 -0
- data/spec/select_feature_dsl_spec.rb +50 -0
- data/spec/select_scen_outline_dsl_spec.rb +126 -0
- data/spec/select_scenario_dsl_spec.rb +73 -0
- data/spec/unit_spec.rb +22 -0
- metadata +21 -4
@@ -0,0 +1,279 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/repo"
|
3
|
+
|
4
|
+
describe "cql" do
|
5
|
+
describe 'tag count' do
|
6
|
+
{
|
7
|
+
0=>[],
|
8
|
+
1=>[],
|
9
|
+
2=>{"name"=> "1 tag"},
|
10
|
+
3=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}],
|
11
|
+
4=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}],
|
12
|
+
5=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}]
|
13
|
+
|
14
|
+
}.each do |number, expected|
|
15
|
+
it "should filter scenarios by the number of tags with the 'tc_lt' operator for count of #{number}" do
|
16
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
|
17
|
+
|
18
|
+
result = gs.query do
|
19
|
+
select name
|
20
|
+
from scenarios
|
21
|
+
with tc_lt number
|
22
|
+
end
|
23
|
+
|
24
|
+
result.should == expected
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
{
|
29
|
+
0=>[],
|
30
|
+
1=>{"name"=> "1 tag"},
|
31
|
+
2=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}],
|
32
|
+
3=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}],
|
33
|
+
4=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
34
|
+
5=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}]
|
35
|
+
|
36
|
+
}.each do |number, expected|
|
37
|
+
it "should filter scenarios by the number of tags with the 'tc_lte' operator for count of #{number}" do
|
38
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
|
39
|
+
|
40
|
+
result = gs.query do
|
41
|
+
select name
|
42
|
+
from scenarios
|
43
|
+
with tc_lte number
|
44
|
+
end
|
45
|
+
|
46
|
+
result.should == expected
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
{
|
51
|
+
0=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
52
|
+
1=>[{"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
53
|
+
2=>[{"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
54
|
+
3=>{"name"=> "4 tags"},
|
55
|
+
4=>[]
|
56
|
+
|
57
|
+
|
58
|
+
}.each do |number, expected|
|
59
|
+
it "should filter scenarios by the number of tags with the 'tc_gt' operator for count of #{number}" do
|
60
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
|
61
|
+
|
62
|
+
result = gs.query do
|
63
|
+
select name
|
64
|
+
from scenarios
|
65
|
+
with tc_gt number
|
66
|
+
end
|
67
|
+
|
68
|
+
result.should == expected
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
{
|
73
|
+
0=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
74
|
+
1=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
75
|
+
2=>[{"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
76
|
+
3=>[{"name"=> "3 tags"}, {"name"=> "4 tags"}],
|
77
|
+
4=>{"name"=> "4 tags"},
|
78
|
+
5 =>[]
|
79
|
+
|
80
|
+
|
81
|
+
}.each do |number, expected|
|
82
|
+
it "should filter scenarios by the number of tags with the 'tc_gte' operator for count of #{number}" do
|
83
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
|
84
|
+
|
85
|
+
result = gs.query do
|
86
|
+
select name
|
87
|
+
from scenarios
|
88
|
+
with tc_gte number
|
89
|
+
end
|
90
|
+
|
91
|
+
result.should == expected
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
describe 'line count' do
|
99
|
+
{
|
100
|
+
0=>[],
|
101
|
+
1=>[],
|
102
|
+
2=>{"name"=> "1 line"},
|
103
|
+
3=>[{"name"=> "1 line"}, {"name"=> "2 lines"}],
|
104
|
+
4=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}],
|
105
|
+
5=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}]
|
106
|
+
|
107
|
+
}.each do |number, expected|
|
108
|
+
it "should filter scenarios by the number of lines with the 'tc_lt' operator for count of #{number}" do
|
109
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
|
110
|
+
|
111
|
+
result = gs.query do
|
112
|
+
select name
|
113
|
+
from scenarios
|
114
|
+
with lc_lt number
|
115
|
+
end
|
116
|
+
|
117
|
+
result.should == expected
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
{
|
122
|
+
0=>[],
|
123
|
+
1=>{"name"=> "1 line"},
|
124
|
+
2=>[{"name"=> "1 line"}, {"name"=> "2 lines"}],
|
125
|
+
3=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}],
|
126
|
+
4=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
127
|
+
5=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}]
|
128
|
+
|
129
|
+
}.each do |number, expected|
|
130
|
+
it "should filter scenarios by the number of lines with the 'lc_lte' operator for count of #{number}" do
|
131
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
|
132
|
+
|
133
|
+
result = gs.query do
|
134
|
+
select name
|
135
|
+
from scenarios
|
136
|
+
with lc_lte number
|
137
|
+
end
|
138
|
+
|
139
|
+
result.should == expected
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
{
|
144
|
+
0=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
145
|
+
1=>[{"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
146
|
+
2=>[{"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
147
|
+
3=>{"name"=> "4 lines"},
|
148
|
+
4=>[]
|
149
|
+
|
150
|
+
|
151
|
+
}.each do |number, expected|
|
152
|
+
it "should filter scenarios by the number of lines with the 'lc_gt' operator for count of #{number}" do
|
153
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
|
154
|
+
|
155
|
+
result = gs.query do
|
156
|
+
select name
|
157
|
+
from scenarios
|
158
|
+
with lc_gt number
|
159
|
+
end
|
160
|
+
|
161
|
+
result.should == expected
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
{
|
166
|
+
0=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
167
|
+
1=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
168
|
+
2=>[{"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
169
|
+
3=>[{"name"=> "3 lines"}, {"name"=> "4 lines"}],
|
170
|
+
4=>{"name"=> "4 lines"},
|
171
|
+
5 =>[]
|
172
|
+
|
173
|
+
|
174
|
+
}.each do |number, expected|
|
175
|
+
it "should filter scenarios by the number of lines with the 'lc_gte' operator for count of #{number}" do
|
176
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
|
177
|
+
|
178
|
+
result = gs.query do
|
179
|
+
select name
|
180
|
+
from scenarios
|
181
|
+
with lc_gte number
|
182
|
+
end
|
183
|
+
|
184
|
+
result.should == expected
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
describe 'exact line match' do
|
192
|
+
it 'should filter based on an exact line' do
|
193
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
|
194
|
+
|
195
|
+
result = gs.query do
|
196
|
+
select name
|
197
|
+
from scenarios
|
198
|
+
with line 'green eggs and ham'
|
199
|
+
end
|
200
|
+
|
201
|
+
result.size.should == 1
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should filter all results when the exact line given does not match' do
|
206
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
|
207
|
+
|
208
|
+
result = gs.query do
|
209
|
+
select name
|
210
|
+
from scenarios
|
211
|
+
with line 'no match'
|
212
|
+
end
|
213
|
+
|
214
|
+
result.size.should == 0
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should filter no results when the exact line given is present in all scenarios' do
|
219
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
|
220
|
+
|
221
|
+
result = gs.query do
|
222
|
+
select name
|
223
|
+
from scenarios
|
224
|
+
with line 'a cat in a hat'
|
225
|
+
end
|
226
|
+
|
227
|
+
result.size.should == 2
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe 'exact line match' do
|
233
|
+
it 'should filter based on a regexp match' do
|
234
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
|
235
|
+
|
236
|
+
result = gs.query do
|
237
|
+
select name
|
238
|
+
from scenarios
|
239
|
+
with line /green/
|
240
|
+
end
|
241
|
+
|
242
|
+
result.size.should == 1
|
243
|
+
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should filter all if no regexp match' do
|
247
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
|
248
|
+
|
249
|
+
result = gs.query do
|
250
|
+
select name
|
251
|
+
from scenarios
|
252
|
+
with line /will not be found/
|
253
|
+
end
|
254
|
+
|
255
|
+
result.size.should == 0
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should filter none if all match regexp' do
|
260
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
|
261
|
+
|
262
|
+
result = gs.query do
|
263
|
+
select name
|
264
|
+
from scenarios
|
265
|
+
with line /cat/
|
266
|
+
end
|
267
|
+
|
268
|
+
result.size.should == 2
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
# Has tag
|
275
|
+
# Name
|
276
|
+
# Name match
|
277
|
+
|
278
|
+
# Example count
|
279
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/repo"
|
3
|
+
|
4
|
+
describe "cql" do
|
5
|
+
|
6
|
+
describe "file parsing" do
|
7
|
+
it 'should find the physical files' do
|
8
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
9
|
+
result = CQL::MapReduce.uri(gs.parsed_feature_files)
|
10
|
+
result[0].should =~ /simple\.feature/
|
11
|
+
result[1].should =~ /test\.feature/
|
12
|
+
result[2].should =~ /test2\.feature/
|
13
|
+
result[3].should =~ /test_full\.feature/
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should filter by count functions' do
|
18
|
+
input = [{"keyword"=>"Feature", "name"=>"f1_4_scenarios_5_so", "line"=>1, "description"=>"", "id"=>"f1-4-scenarios-5-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f1_4_scenarios_5_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f1_scen1", "line"=>3, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f1_scen2", "line"=>7, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f1_scen3", "line"=>11, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario", "name"=>"f1_scen4", "line"=>15, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen4", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>16}, {"keyword"=>"Then ", "name"=>"something else", "line"=>17}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so1", "line"=>19, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>20}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>22, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so1;", "rows"=>[{"cells"=>["e"], "line"=>23, "id"=>"f1-4-scenarios-5-so;f1-so1;;1"}, {"cells"=>["r"], "line"=>24, "id"=>"f1-4-scenarios-5-so;f1-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so2", "line"=>26, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>27}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>29, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so2;", "rows"=>[{"cells"=>["e"], "line"=>30, "id"=>"f1-4-scenarios-5-so;f1-so2;;1"}, {"cells"=>["r"], "line"=>31, "id"=>"f1-4-scenarios-5-so;f1-so2;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so3", "line"=>33, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so3", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>34}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>36, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so3;", "rows"=>[{"cells"=>["e"], "line"=>37, "id"=>"f1-4-scenarios-5-so;f1-so3;;1"}, {"cells"=>["r"], "line"=>38, "id"=>"f1-4-scenarios-5-so;f1-so3;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so4", "line"=>40, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so4", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>41}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>43, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so4;", "rows"=>[{"cells"=>["e"], "line"=>44, "id"=>"f1-4-scenarios-5-so;f1-so4;;1"}, {"cells"=>["r"], "line"=>45, "id"=>"f1-4-scenarios-5-so;f1-so4;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so5", "line"=>47, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so5", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>48}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>50, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so5;", "rows"=>[{"cells"=>["e"], "line"=>51, "id"=>"f1-4-scenarios-5-so;f1-so5;;1"}, {"cells"=>["r"], "line"=>52, "id"=>"f1-4-scenarios-5-so;f1-so5;;2"}]}]}]},
|
19
|
+
{"keyword"=>"Feature", "name"=>"f2_7_scenarios_2_so", "line"=>1, "description"=>"", "id"=>"f2-7-scenarios-2-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f2_7_scenarios_2_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f2_scen1", "line"=>3, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f2_scen2", "line"=>7, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f2_scen3", "line"=>11, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario", "name"=>"f2_scen4", "line"=>15, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen4", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>16}, {"keyword"=>"Then ", "name"=>"something else", "line"=>17}]}, {"keyword"=>"Scenario", "name"=>"f2_scen5", "line"=>19, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen5", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>20}, {"keyword"=>"Then ", "name"=>"something else", "line"=>21}]}, {"keyword"=>"Scenario", "name"=>"f2_scen6", "line"=>23, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen6", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>24}, {"keyword"=>"Then ", "name"=>"something else", "line"=>25}]}, {"keyword"=>"Scenario", "name"=>"f2_scen7", "line"=>27, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen7", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>28}, {"keyword"=>"Then ", "name"=>"something else", "line"=>29}]}, {"keyword"=>"Scenario Outline", "name"=>"f2_so1", "line"=>31, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>32}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>34, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so1;", "rows"=>[{"cells"=>["e"], "line"=>35, "id"=>"f2-7-scenarios-2-so;f2-so1;;1"}, {"cells"=>["r"], "line"=>36, "id"=>"f2-7-scenarios-2-so;f2-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f2_so2", "line"=>38, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>39}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>41, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so2;", "rows"=>[{"cells"=>["e"], "line"=>42, "id"=>"f2-7-scenarios-2-so;f2-so2;;1"}, {"cells"=>["r"], "line"=>43}]}]}]},
|
20
|
+
{"keyword"=>"Feature", "name"=>"f3_2_scenarios_3_so", "line"=>1, "description"=>"", "id"=>"f3-2-scenarios-3-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f3_2_scenarios_3_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f3_scen1", "line"=>3, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f3_scen2", "line"=>7, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f3_scen3", "line"=>11, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so1", "line"=>15, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>16}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>18, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so1;", "rows"=>[{"cells"=>["e"], "line"=>19, "id"=>"f3-2-scenarios-3-so;f3-so1;;1"}, {"cells"=>["r"], "line"=>20, "id"=>"f3-2-scenarios-3-so;f3-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so2", "line"=>22, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>23}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>25, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so2;", "rows"=>[{"cells"=>["e"], "line"=>26, "id"=>"f3-2-scenarios-3-so;f3-so2;;1"}, {"cells"=>["r"], "line"=>27, "id"=>"f3-2-scenarios-3-so;f3-so2;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so3", "line"=>29, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so3", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>30}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>32, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so3;", "rows"=>[{"cells"=>["e"], "line"=>33, "id"=>"f3-2-scenarios-3-so;f3-so3;;1"}, {"cells"=>["r"], "line"=>34, "id"=>"f3-2-scenarios-3-so;f3-so3;;2"}]}]}]}]
|
21
|
+
result = CQL::MapReduce.filter_features(input, {'sc_gt'=>2})
|
22
|
+
result.size.should == 3
|
23
|
+
|
24
|
+
result = CQL::MapReduce.filter_features(input, {'sc_gt'=>0})
|
25
|
+
result.size.should == 3
|
26
|
+
|
27
|
+
result = CQL::MapReduce.filter_features(input, {'sc_gt'=>3})
|
28
|
+
result.size.should == 2
|
29
|
+
|
30
|
+
result = CQL::MapReduce.filter_features(input, {'sc_gt'=>7})
|
31
|
+
result.size.should == 0
|
32
|
+
|
33
|
+
result = CQL::MapReduce.filter_features(input, {'sc_gt'=>4})
|
34
|
+
result.size.should == 1
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'filter by tag count' do
|
38
|
+
it 'should filter by tag count' do
|
39
|
+
input = [
|
40
|
+
{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
41
|
+
"elements"=>[
|
42
|
+
{"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
43
|
+
{"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
44
|
+
{"keyword"=>"Feature", "name"=>"Simple2", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[
|
45
|
+
{"keyword"=>"Scenario", "name"=>"3 tags", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}, {"name"=>"@two", "line"=>3}, {"name"=>"@three", "line"=>3}], "id"=>"simple;3-tags", "type"=>"scenario"},
|
46
|
+
{"keyword"=>"Scenario", "name"=>"4 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}, {"name"=>"@three", "line"=>11}, {"name"=>"@four", "line"=>11}], "id"=>"simple;4-tags", "type"=>"scenario", }]}
|
47
|
+
]
|
48
|
+
|
49
|
+
expected = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
50
|
+
"elements"=>[
|
51
|
+
{"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
52
|
+
{"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
53
|
+
{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[]}]
|
54
|
+
CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).size.should == expected.size
|
55
|
+
CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).first['elements'].size.should == expected.first['elements'].size
|
56
|
+
CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3})[1]['elements'].size.should == expected[1]['elements'].size
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "tags" do
|
62
|
+
it "retrieve tags from a scenario" do
|
63
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tags2"
|
64
|
+
CQL::MapReduce.tag_set(gs.parsed_feature_files).sort.should == ["@five", "@four", "@one", "@two"].sort
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should filter features by tag' do
|
68
|
+
input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"simple", "uri"=>"/a/a"},
|
69
|
+
{"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
70
|
+
{"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>1, "description"=>"", "id"=>"test2-feature"},
|
71
|
+
{"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test3-feature"}]
|
72
|
+
result = CQL::MapReduce.filter_features(input, 'tags'=>['@one'])
|
73
|
+
result.size.should == 2
|
74
|
+
result[0]['name'].should == "Test Feature"
|
75
|
+
result[1]['name'].should == "Test3 Feature"
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should filter by multiple tags' do
|
79
|
+
input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple"},
|
80
|
+
{"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
81
|
+
{"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"test2-feature"},
|
82
|
+
{"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}], "id"=>"test3-feature"}]
|
83
|
+
result = CQL::MapReduce.filter_features(input, 'tags'=>['@one', '@two'])
|
84
|
+
result.should == [{"keyword"=>"Feature", "name"=>"Test3 Feature",
|
85
|
+
"line"=>2, "description"=>"",
|
86
|
+
"tags"=>[{"name"=>"@one", "line"=>1},
|
87
|
+
{"name"=>"@two", "line"=>1}],
|
88
|
+
"id"=>"test3-feature"}]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'features query' do
|
93
|
+
it 'should find all feature names' do
|
94
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
95
|
+
CQL::MapReduce.name(gs.parsed_feature_files).should eql ["Simple", "Test Feature", "Test2 Feature", "Test3 Feature"]
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should retrieve a full feature' do
|
99
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
|
100
|
+
result = CQL::MapReduce.filter_features(gs.parsed_feature_files, {'feature'=>["Test Feature"]})
|
101
|
+
result[0]['name'].should == "Test Feature"
|
102
|
+
result[0]['elements'][0]['name'].should == "Testing the slurping 1"
|
103
|
+
result[0]['elements'].should == [{"keyword"=>"Scenario", "name"=>"Testing the slurping 1", "line"=>3,
|
104
|
+
"description"=>"", "id"=>"test-feature;testing-the-slurping-1", "type"=>"scenario",
|
105
|
+
"steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
|
106
|
+
{"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}]},
|
107
|
+
{"keyword"=>"Scenario", "name"=>"Testing the slurping not to be found", "line"=>7,
|
108
|
+
"description"=>"", "id"=>"test-feature;testing-the-slurping-not-to-be-found", "type"=>"scenario",
|
109
|
+
"steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>8}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>9}]}]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'scenario query' do
|
114
|
+
it 'should get all scenarios as a list' do
|
115
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
116
|
+
result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=>'scenario'})
|
117
|
+
result.should == [{"keyword"=>"Scenario", "name"=>"A Scenario", "line"=>13, "description"=>"", "id"=>"test-feature;a-scenario", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>14}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>15}]}]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'scenario outline query' do
|
122
|
+
it 'should get scenario outlines as a list' do
|
123
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
124
|
+
result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=> 'scenario'})
|
125
|
+
result.should == [{"keyword"=>"Scenario", "name"=>"A Scenario", "line"=>13, "description"=>"", "id"=>"test-feature;a-scenario", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>14}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>15}]}]
|
126
|
+
|
127
|
+
result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=> ["Test Feature"], 'what'=> 'scenario_outline'})
|
128
|
+
result.should == [{"keyword"=>"Scenario Outline", "name"=>"An Outline", "line"=>3, "description"=>"", "id"=>"test-feature;an-outline", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;", "rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"}, {"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"}, {"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"}, {"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"}, {"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]}]}]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/repo"
|
3
|
+
|
4
|
+
describe "select" do
|
5
|
+
describe "feature" do
|
6
|
+
it 'should return multiple feature file names' do
|
7
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
8
|
+
result = gs.query do
|
9
|
+
select name
|
10
|
+
from features
|
11
|
+
end
|
12
|
+
result.should == [{"name"=>"Simple"}, {"name"=>"Test Feature"},
|
13
|
+
{"name"=>"Test2 Feature"}, {"name"=>"Test3 Feature"}]
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should find the feature description' do
|
17
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple2"
|
18
|
+
result = gs.query do
|
19
|
+
select description
|
20
|
+
from features
|
21
|
+
end
|
22
|
+
result.should == {"description"=>"The cat in the hat"}
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should find the feature file uri' do
|
26
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
27
|
+
result = gs.query do
|
28
|
+
select uri
|
29
|
+
from features
|
30
|
+
end
|
31
|
+
result[0]['uri'].should =~ /simple\.feature/
|
32
|
+
result[1]['uri'].should =~ /test\.feature/
|
33
|
+
result[2]['uri'].should =~ /test2\.feature/
|
34
|
+
result[3]['uri'].should =~ /test\_full\.feature/
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return multiple feature file names with associated tags' do
|
38
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tagged_features"
|
39
|
+
result = gs.query do
|
40
|
+
select name, tags
|
41
|
+
from features
|
42
|
+
end
|
43
|
+
result.should == [{"name"=>"Simple", "tags"=>nil},
|
44
|
+
{"name"=>"Test Feature", "tags"=>[{"name"=>"@one", "line"=>1}]},
|
45
|
+
{"name"=>"Test2 Feature", "tags"=>[{"name"=>"@two", "line"=>1}]},
|
46
|
+
{"name"=>"Test3 Feature", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}]}]
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|