cql 0.1.2 → 0.1.3

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.
@@ -1,279 +1,288 @@
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
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
+ }.each do |number, expected|
14
+ it "should filter scenarios by the number of tags with the 'tc lt' operator for count of #{number}" do
15
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
16
+
17
+ result = gs.query do
18
+ select name
19
+ from scenarios
20
+ with tc lt number
21
+ end
22
+
23
+ result.should == expected
24
+ end
25
+ end
26
+
27
+ {
28
+ 0=>[],
29
+ 1=>{"name"=> "1 tag"},
30
+ 2=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}],
31
+ 3=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}],
32
+ 4=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
33
+ 5=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}]
34
+
35
+ }.each do |number, expected|
36
+ it "should filter scenarios by the number of tags with the 'tc_lte' operator for count of #{number}" do
37
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
38
+
39
+ result = gs.query do
40
+ select name
41
+ from scenarios
42
+ with tc lte number
43
+ end
44
+
45
+ result.should == expected
46
+ end
47
+ end
48
+
49
+ {
50
+ 0=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
51
+ 1=>[{"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
52
+ 2=>[{"name"=> "3 tags"}, {"name"=> "4 tags"}],
53
+ 3=>{"name"=> "4 tags"},
54
+ 4=>[]
55
+ }.each do |number, expected|
56
+ it "should filter scenarios by the number of tags with the 'tc_gt' operator for count of #{number}" do
57
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
58
+
59
+ result = gs.query do
60
+ select name
61
+ from scenarios
62
+ with tc gt number
63
+ end
64
+
65
+ result.should == expected
66
+ end
67
+ end
68
+
69
+ {
70
+ 0=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
71
+ 1=>[{"name"=> "1 tag"}, {"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
72
+ 2=>[{"name"=> "2 tags"}, {"name"=> "3 tags"}, {"name"=> "4 tags"}],
73
+ 3=>[{"name"=> "3 tags"}, {"name"=> "4 tags"}],
74
+ 4=>{"name"=> "4 tags"},
75
+ 5 =>[]
76
+ }.each do |number, expected|
77
+ it "should filter scenarios by the number of tags with the 'tc_gte' operator for count of #{number}" do
78
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tag_count"
79
+
80
+ result = gs.query do
81
+ select name
82
+ from scenarios
83
+ with tc gte number
84
+ end
85
+
86
+ result.should == expected
87
+ end
88
+ end
89
+
90
+
91
+ end
92
+
93
+ describe 'line count' do
94
+ {
95
+ 0=>[],
96
+ 1=>[],
97
+ 2=>{"name"=> "1 line"},
98
+ 3=>[{"name"=> "1 line"}, {"name"=> "2 lines"}],
99
+ 4=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}],
100
+ 5=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}]
101
+
102
+ }.each do |number, expected|
103
+ it "should filter scenarios by the number of lines with the 'lc_lt' operator for count of #{number}" do
104
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
105
+
106
+ result = gs.query do
107
+ select name
108
+ from scenarios
109
+ with lc lt number
110
+ end
111
+
112
+ result.should == expected
113
+ end
114
+ end
115
+
116
+ {
117
+ 0=>[],
118
+ 1=>{"name"=> "1 line"},
119
+ 2=>[{"name"=> "1 line"}, {"name"=> "2 lines"}],
120
+ 3=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}],
121
+ 4=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
122
+ 5=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}]
123
+
124
+ }.each do |number, expected|
125
+ it "should filter scenarios by the number of lines with the 'lc_lte' operator for count of #{number}" do
126
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
127
+
128
+ result = gs.query do
129
+ select name
130
+ from scenarios
131
+ with lc lte number
132
+ end
133
+
134
+ result.should == expected
135
+ end
136
+ end
137
+
138
+ {
139
+ 0=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
140
+ 1=>[{"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
141
+ 2=>[{"name"=> "3 lines"}, {"name"=> "4 lines"}],
142
+ 3=>{"name"=> "4 lines"},
143
+ 4=>[]
144
+
145
+
146
+ }.each do |number, expected|
147
+ it "should filter scenarios by the number of lines with the 'lc_gt' operator for count of #{number}" do
148
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
149
+
150
+ result = gs.query do
151
+ select name
152
+ from scenarios
153
+ with lc gt number
154
+ end
155
+
156
+ result.should == expected
157
+ end
158
+ end
159
+
160
+ {
161
+ 0=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
162
+ 1=>[{"name"=> "1 line"}, {"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
163
+ 2=>[{"name"=> "2 lines"}, {"name"=> "3 lines"}, {"name"=> "4 lines"}],
164
+ 3=>[{"name"=> "3 lines"}, {"name"=> "4 lines"}],
165
+ 4=>{"name"=> "4 lines"},
166
+ 5 =>[]
167
+
168
+
169
+ }.each do |number, expected|
170
+ it "should filter scenarios by the number of lines with the 'lc_gte' operator for count of #{number}" do
171
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_count"
172
+
173
+ result = gs.query do
174
+ select name
175
+ from scenarios
176
+ with lc gte number
177
+ end
178
+
179
+ result.should == expected
180
+ end
181
+ end
182
+
183
+
184
+ end
185
+
186
+ describe 'exact line match' do
187
+ it 'should filter based on an exact line' do
188
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
189
+
190
+ result = gs.query do
191
+ select name
192
+ from scenarios
193
+ with line 'green eggs and ham'
194
+ end
195
+
196
+ result.size.should == 1
197
+
198
+ end
199
+
200
+ it 'should filter all results when the exact line given does not match' do
201
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
202
+
203
+ result = gs.query do
204
+ select name
205
+ from scenarios
206
+ with line 'no match'
207
+ end
208
+
209
+ result.size.should == 0
210
+
211
+ end
212
+
213
+ it 'should filter no results when the exact line given is present in all scenarios' do
214
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
215
+
216
+ result = gs.query do
217
+ select name
218
+ from scenarios
219
+ with line 'a cat in a hat'
220
+ end
221
+
222
+ result.size.should == 2
223
+
224
+ end
225
+ end
226
+
227
+ describe 'exact line match' do
228
+ it 'should filter based on a regexp match' do
229
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
230
+
231
+ result = gs.query do
232
+ select name
233
+ from scenarios
234
+ with line /green/
235
+ end
236
+
237
+ result.size.should == 1
238
+
239
+ end
240
+
241
+ it 'should filter all if no regexp match' do
242
+ gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
243
+
244
+ result = gs.query do
245
+ select name
246
+ from scenarios
247
+ with line /will not be found/
248
+ end
249
+
250
+ result.size.should == 0
251
+
252
+ end
253
+
254
+ it 'should filter none if all match regexp' do
255
+ repo = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/line_filter"
256
+
257
+ result = repo.query do
258
+ select name
259
+ from scenarios
260
+ with line /cat/
261
+ end
262
+
263
+ result.size.should == 2
264
+
265
+ end
266
+
267
+ end
268
+
269
+ describe 'tag search' do
270
+ it 'should return scenarios with matching tags' do
271
+ repo = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tags"
272
+
273
+ result = repo.query do
274
+ select name
275
+ from scenarios
276
+ with tags '@one'
277
+ end
278
+
279
+ result.should == [{'name'=>'Next'},{'name'=>'Another'}]
280
+ end
281
+ end
282
+
283
+ # Has tag
284
+ # Name
285
+ # Name match
286
+
287
+ # Example count
279
288
  end