cql 1.4.1 → 1.7.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 +5 -5
- data/lib/cql/dsl.rb +11 -1
- data/lib/cql/filters.rb +14 -1
- data/lib/cql/query.rb +5 -2
- data/lib/cql/repository.rb +1 -0
- data/lib/cql/version.rb +1 -1
- data/testing/cucumber/features/clauses/from_clause.feature +0 -8
- data/testing/cucumber/features/clauses/predefined_with_filters.feature +392 -0
- data/testing/cucumber/features/clauses/select_clause.feature +1 -5
- data/testing/cucumber/features/clauses/with_clause.feature +2 -164
- data/testing/cucumber/features/dsl.feature +0 -22
- data/testing/cucumber/step_definitions/verification_steps.rb +5 -6
- data/testing/gemfiles/cuke_modeler0.gemfile +9 -7
- data/testing/gemfiles/cuke_modeler1.gemfile +5 -7
- data/testing/gemfiles/cuke_modeler2.gemfile +33 -0
- data/testing/gemfiles/cuke_modeler3.gemfile +10 -0
- data/testing/helper_methods.rb +13 -0
- data/testing/model_helper.rb +28 -0
- data/testing/rspec/spec/clauses/as_clause_spec.rb +1 -0
- data/testing/rspec/spec/clauses/from_clause_spec.rb +146 -0
- data/testing/rspec/spec/clauses/select_clause_spec.rb +184 -0
- data/testing/rspec/spec/clauses/transform_clause_spec.rb +35 -0
- data/testing/rspec/spec/clauses/with_clause_spec.rb +84 -0
- data/testing/rspec/spec/clauses/without_clause_spec.rb +171 -0
- data/testing/rspec/spec/cql_spec.rb +31 -0
- data/testing/rspec/spec/dsl_spec.rb +3 -575
- data/testing/rspec/spec/filter_example_spec.rb +1 -1
- data/testing/rspec/spec/filter_feature_dsl_spec.rb +13 -13
- data/testing/rspec/spec/filter_sso_spec.rb +2 -2
- data/testing/rspec/spec/line_filterable_specs.rb +1 -1
- data/testing/rspec/spec/map_reduce_spec.rb +1 -1
- data/testing/rspec/spec/model_query_spec.rb +1 -1
- data/testing/rspec/spec/multiple_queries_spec.rb +1 -1
- data/testing/rspec/spec/name_filterable_specs.rb +1 -1
- data/testing/rspec/spec/predefined_filters_spec.rb +284 -0
- data/testing/rspec/spec/repository_spec.rb +3 -3
- data/testing/rspec/spec/select_feature_dsl_spec.rb +8 -8
- data/testing/rspec/spec/select_scen_outline_dsl_spec.rb +14 -14
- data/testing/rspec/spec/select_scenario_dsl_spec.rb +9 -9
- data/testing/rspec/spec/spec_helper.rb +7 -17
- metadata +67 -40
- data/testing/cucumber/support/transforms.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c95630cf653362dc9364c4ffe7c5099efbd779abec07c8fe42ebb4fffc23008b
|
4
|
+
data.tar.gz: 7f1c6a3f3e728fe9b92ad1ba1df4001d5a10cca8469997a47bf82c6f0b301664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d449609ec93c7ef3cece4da854e6b2ecb83198eb02bfe9f17688974f9ee3aa8f17bf5dcf94241ebdbb201414f18fc938bdca86b16141f7937246a903abbef070
|
7
|
+
data.tar.gz: c7b9588db438b973b1714d2191f5725ba17ad30aa363d6f8d10337767d86616fd982ea603fc266628209518de0d2a6c4d265dbfe043c19f0966f88387254a279
|
data/lib/cql/dsl.rb
CHANGED
@@ -80,8 +80,13 @@ module CQL
|
|
80
80
|
|
81
81
|
# Not a part of the public API. Subject to change at any time.
|
82
82
|
class Comparison
|
83
|
-
attr_accessor :operator, :amount
|
84
83
|
|
84
|
+
# the operator used for comparison
|
85
|
+
attr_accessor :operator,
|
86
|
+
# value that will be compared against
|
87
|
+
:amount
|
88
|
+
|
89
|
+
# Creates a new comparison object
|
85
90
|
def initialize operator, amount
|
86
91
|
@operator = operator
|
87
92
|
@amount = amount
|
@@ -134,6 +139,11 @@ module CQL
|
|
134
139
|
Comparison.new '<=', amount
|
135
140
|
end
|
136
141
|
|
142
|
+
# Adds an *eq* filter operator to the query. See the corresponding Cucumber documentation for details.
|
143
|
+
def eq amount
|
144
|
+
Comparison.new '==', amount
|
145
|
+
end
|
146
|
+
|
137
147
|
# Adds a *tags* filter to the query. See the corresponding Cucumber documentation for details.
|
138
148
|
def tags *tags
|
139
149
|
return "tags" if tags.size == 0
|
data/lib/cql/filters.rb
CHANGED
@@ -2,12 +2,16 @@ module CQL
|
|
2
2
|
|
3
3
|
# Not a part of the public API. Subject to change at any time.
|
4
4
|
class TagFilter
|
5
|
+
|
6
|
+
# Tags to match
|
5
7
|
attr_reader :tags
|
6
8
|
|
9
|
+
# Creates a new filter
|
7
10
|
def initialize tags
|
8
11
|
@tags = tags
|
9
12
|
end
|
10
13
|
|
14
|
+
# Returns whether or not the object has the target tags
|
11
15
|
def has_tags?(object, target_tags)
|
12
16
|
target_tags.all? { |target_tag|
|
13
17
|
tags = object.tags
|
@@ -27,14 +31,18 @@ module CQL
|
|
27
31
|
|
28
32
|
# Not a part of the public API. Subject to change at any time.
|
29
33
|
class ContentMatchFilter
|
34
|
+
|
35
|
+
# Pattern to match
|
30
36
|
attr_reader :pattern
|
31
37
|
|
38
|
+
# Creates a new filter
|
32
39
|
def initialize(pattern)
|
33
40
|
raise(ArgumentError, "Can only match a String or Regexp. Got #{pattern.class}.") unless pattern.is_a?(String) || pattern.is_a?(Regexp)
|
34
41
|
|
35
42
|
@pattern = pattern
|
36
43
|
end
|
37
44
|
|
45
|
+
# Returns whether or not the content matches the pattern
|
38
46
|
def content_match?(content)
|
39
47
|
if pattern.is_a?(String)
|
40
48
|
content.any? { |thing| thing == pattern }
|
@@ -47,8 +55,13 @@ module CQL
|
|
47
55
|
|
48
56
|
# Not a part of the public API. Subject to change at any time.
|
49
57
|
class TypeCountFilter
|
50
|
-
attr_reader :types, :comparison
|
51
58
|
|
59
|
+
# the types of object that will be filtered against
|
60
|
+
attr_reader :types,
|
61
|
+
# the comparison that will be made between the objects
|
62
|
+
:comparison
|
63
|
+
|
64
|
+
# Creates a new filter
|
52
65
|
def initialize types, comparison
|
53
66
|
@types = types
|
54
67
|
@comparison = comparison
|
data/lib/cql/query.rb
CHANGED
@@ -5,9 +5,12 @@ module CQL
|
|
5
5
|
|
6
6
|
include Dsl
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
# the root object that will be queried
|
9
|
+
attr_reader :data,
|
10
|
+
# what kinds of objects will be selected
|
11
|
+
:what
|
10
12
|
|
13
|
+
# Creates a new query object
|
11
14
|
def initialize(directory, &block)
|
12
15
|
# Set root object
|
13
16
|
@data = directory
|
data/lib/cql/repository.rb
CHANGED
data/lib/cql/version.rb
CHANGED
@@ -119,11 +119,3 @@ Feature: 'from' clause
|
|
119
119
|
from :all
|
120
120
|
"""
|
121
121
|
Then all models are queried from
|
122
|
-
|
123
|
-
|
124
|
-
# Commented out so that they aren't picked up by Relish
|
125
|
-
# @wip
|
126
|
-
# Scenario: Can 'from' from all type of model
|
127
|
-
#
|
128
|
-
# @wip
|
129
|
-
# Scenario: From-ing from a collection
|
@@ -0,0 +1,392 @@
|
|
1
|
+
# todo - Rewrite the scenarios such that they use their own test specific feature files instead of setting up a large suite in the background
|
2
|
+
Feature: 'with' clause
|
3
|
+
|
4
|
+
There are several predefined filters that can be used with the *with* clause. Like regular 'block style' conditions, they can be negated using *without*, used in a targeted fashion, etc.
|
5
|
+
|
6
|
+
Sample usage:
|
7
|
+
````
|
8
|
+
cql_repo.query do
|
9
|
+
select name, tags, description_text
|
10
|
+
from features
|
11
|
+
with tc lt 3
|
12
|
+
end
|
13
|
+
````
|
14
|
+
|
15
|
+
The following filters are supported for models that have tags:
|
16
|
+
|
17
|
+
* tags - Filters out models that do not have the exact set of tags provided.
|
18
|
+
* tc - (tag count) Filters out models based on the number of tags that they have.
|
19
|
+
|
20
|
+
The following filters are supported for models that have names:
|
21
|
+
|
22
|
+
* name - Filters out models whose name does not match the name provided. Can be a string or regular expression.
|
23
|
+
|
24
|
+
The following filters are supported for models that have steps:
|
25
|
+
|
26
|
+
* line - Filters out models whose steps do not include the provided step (keywords and blocks are ignored). Can be a string or regular expression.
|
27
|
+
* lc - (line count) Filters out models based on the number of steps that they have.
|
28
|
+
|
29
|
+
The following filters are supported for feature models:
|
30
|
+
|
31
|
+
* sc - (scenario count) Filters out models based on the number of scenarios that they have.
|
32
|
+
* soc - (scenario outline count) Filters out models based on the number of outlines that they have.
|
33
|
+
* ssoc - (scenario and scenario outline count) Filters out models based on the total number of scenarios and outlines that they have.
|
34
|
+
|
35
|
+
For count based filters, the following operators are available:
|
36
|
+
|
37
|
+
* lt (Less than)
|
38
|
+
* lte (Less than or equals)
|
39
|
+
* gt (Greater than)
|
40
|
+
* gte (Greater than or equals)
|
41
|
+
* eq (Equals)
|
42
|
+
|
43
|
+
|
44
|
+
Background: A sample Cucumber suite
|
45
|
+
Given a repository to query
|
46
|
+
And the following feature has been modeled in the repository:
|
47
|
+
"""
|
48
|
+
Feature: A test feature
|
49
|
+
|
50
|
+
@tag_1 @tag_2
|
51
|
+
Scenario: Test 1
|
52
|
+
* some steps
|
53
|
+
|
54
|
+
@special_tag @tag_2
|
55
|
+
Scenario: Test 2
|
56
|
+
* some other steps
|
57
|
+
* some other steps
|
58
|
+
* some other steps
|
59
|
+
|
60
|
+
@a @b @c
|
61
|
+
Scenario Outline: Test 3
|
62
|
+
* some steps
|
63
|
+
* some more steps
|
64
|
+
* some more steps
|
65
|
+
* some more steps
|
66
|
+
Examples: First examples
|
67
|
+
| param |
|
68
|
+
| value |
|
69
|
+
Examples: Second examples
|
70
|
+
| param |
|
71
|
+
| value |
|
72
|
+
|
73
|
+
Scenario: Test 4
|
74
|
+
"""
|
75
|
+
And the following feature has been modeled in the repository:
|
76
|
+
"""
|
77
|
+
Feature: A feature with lots of scenarios
|
78
|
+
|
79
|
+
Scenario: 1
|
80
|
+
* different steps
|
81
|
+
* different steps
|
82
|
+
|
83
|
+
Scenario: 2
|
84
|
+
* different steps
|
85
|
+
* different steps
|
86
|
+
|
87
|
+
Scenario: 3
|
88
|
+
* different steps
|
89
|
+
* different steps
|
90
|
+
"""
|
91
|
+
And the following feature has been modeled in the repository:
|
92
|
+
"""
|
93
|
+
Feature: A feature with lots of outlines
|
94
|
+
|
95
|
+
Scenario Outline: 1
|
96
|
+
* different steps
|
97
|
+
* different steps
|
98
|
+
Examples:
|
99
|
+
| param |
|
100
|
+
| value |
|
101
|
+
|
102
|
+
Scenario Outline: 2
|
103
|
+
* different steps
|
104
|
+
* different steps
|
105
|
+
Examples:
|
106
|
+
| param |
|
107
|
+
| value |
|
108
|
+
|
109
|
+
Scenario Outline: 3
|
110
|
+
* different steps
|
111
|
+
* different steps
|
112
|
+
Examples:
|
113
|
+
| param |
|
114
|
+
| value |
|
115
|
+
"""
|
116
|
+
And the following feature has been modeled in the repository:
|
117
|
+
"""
|
118
|
+
Feature: A feature with a mix of tests
|
119
|
+
|
120
|
+
Scenario: 4
|
121
|
+
* different steps
|
122
|
+
* different steps
|
123
|
+
|
124
|
+
Scenario Outline: 4
|
125
|
+
* different steps
|
126
|
+
* different steps
|
127
|
+
Examples:
|
128
|
+
| param |
|
129
|
+
| value |
|
130
|
+
"""
|
131
|
+
|
132
|
+
|
133
|
+
Scenario: Filtering by tags
|
134
|
+
When the following query is executed:
|
135
|
+
"""
|
136
|
+
select name
|
137
|
+
from scenarios
|
138
|
+
with tags '@tag_1', '@tag_2'
|
139
|
+
"""
|
140
|
+
Then the following values are returned:
|
141
|
+
| name |
|
142
|
+
| Test 1 |
|
143
|
+
|
144
|
+
Scenario: Filtering by tag count
|
145
|
+
When the following query is executed:
|
146
|
+
"""
|
147
|
+
select name
|
148
|
+
from scenarios, outlines
|
149
|
+
with tc gt 2
|
150
|
+
"""
|
151
|
+
Then the following values are returned:
|
152
|
+
| name |
|
153
|
+
| Test 3 |
|
154
|
+
|
155
|
+
Scenario: Filtering by name (exact match)
|
156
|
+
When the following query is executed:
|
157
|
+
"""
|
158
|
+
select name
|
159
|
+
from scenarios, outlines
|
160
|
+
with name 'Test 3'
|
161
|
+
"""
|
162
|
+
Then the following values are returned:
|
163
|
+
| name |
|
164
|
+
| Test 3 |
|
165
|
+
|
166
|
+
Scenario: Filtering by name (regular expression)
|
167
|
+
When the following query is executed:
|
168
|
+
"""
|
169
|
+
select name
|
170
|
+
from scenarios, outlines
|
171
|
+
with name /Test [12]/
|
172
|
+
"""
|
173
|
+
Then the following values are returned:
|
174
|
+
| name |
|
175
|
+
| Test 1 |
|
176
|
+
| Test 2 |
|
177
|
+
|
178
|
+
Scenario: Filtering by line (exact match)
|
179
|
+
When the following query is executed:
|
180
|
+
"""
|
181
|
+
select name
|
182
|
+
from scenarios, outlines
|
183
|
+
with line 'some steps'
|
184
|
+
"""
|
185
|
+
Then the following values are returned:
|
186
|
+
| name |
|
187
|
+
| Test 1 |
|
188
|
+
| Test 3 |
|
189
|
+
|
190
|
+
Scenario: Filtering by line (regular expression)
|
191
|
+
When the following query is executed:
|
192
|
+
"""
|
193
|
+
select name
|
194
|
+
from scenarios, outlines
|
195
|
+
with line /other/
|
196
|
+
"""
|
197
|
+
Then the following values are returned:
|
198
|
+
| name |
|
199
|
+
| Test 2 |
|
200
|
+
|
201
|
+
Scenario: Filtering by line count
|
202
|
+
When the following query is executed:
|
203
|
+
"""
|
204
|
+
select name
|
205
|
+
from scenarios, outlines
|
206
|
+
with lc gt 3
|
207
|
+
"""
|
208
|
+
Then the following values are returned:
|
209
|
+
| name |
|
210
|
+
| Test 3 |
|
211
|
+
|
212
|
+
Scenario: Filtering by scenario count
|
213
|
+
When the following query is executed:
|
214
|
+
"""
|
215
|
+
select name
|
216
|
+
from features
|
217
|
+
with sc gt 2
|
218
|
+
"""
|
219
|
+
Then the following values are returned:
|
220
|
+
| name |
|
221
|
+
| A test feature |
|
222
|
+
| A feature with lots of scenarios |
|
223
|
+
|
224
|
+
Scenario: Filtering by outline count
|
225
|
+
When the following query is executed:
|
226
|
+
"""
|
227
|
+
select name
|
228
|
+
from features
|
229
|
+
with soc gt 2
|
230
|
+
"""
|
231
|
+
Then the following values are returned:
|
232
|
+
| name |
|
233
|
+
| A feature with lots of outlines |
|
234
|
+
|
235
|
+
Scenario: Filtering by combined test count
|
236
|
+
When the following query is executed:
|
237
|
+
"""
|
238
|
+
select name
|
239
|
+
from features
|
240
|
+
with ssoc lt 3
|
241
|
+
"""
|
242
|
+
Then the following values are returned:
|
243
|
+
| name |
|
244
|
+
| A feature with a mix of tests |
|
245
|
+
|
246
|
+
Scenario: Using the 'lt' count filter
|
247
|
+
When the following query is executed:
|
248
|
+
"""
|
249
|
+
select name
|
250
|
+
from features
|
251
|
+
with ssoc lt 3
|
252
|
+
"""
|
253
|
+
Then the following values are returned:
|
254
|
+
| name |
|
255
|
+
| A feature with a mix of tests |
|
256
|
+
|
257
|
+
Scenario: Using the 'lte' count filter
|
258
|
+
When the following query is executed:
|
259
|
+
"""
|
260
|
+
select name
|
261
|
+
from scenarios, outlines
|
262
|
+
with lc lte 1
|
263
|
+
"""
|
264
|
+
Then the following values are returned:
|
265
|
+
| name |
|
266
|
+
| Test 1 |
|
267
|
+
| Test 4 |
|
268
|
+
|
269
|
+
Scenario: Using the 'gt' count filter
|
270
|
+
When the following query is executed:
|
271
|
+
"""
|
272
|
+
select name
|
273
|
+
from scenarios, outlines
|
274
|
+
with lc gt 3
|
275
|
+
"""
|
276
|
+
Then the following values are returned:
|
277
|
+
| name |
|
278
|
+
| Test 3 |
|
279
|
+
|
280
|
+
Scenario: Using the 'gte' count filter
|
281
|
+
When the following query is executed:
|
282
|
+
"""
|
283
|
+
select name
|
284
|
+
from scenarios, outlines
|
285
|
+
with lc gte 3
|
286
|
+
"""
|
287
|
+
Then the following values are returned:
|
288
|
+
| name |
|
289
|
+
| Test 2 |
|
290
|
+
| Test 3 |
|
291
|
+
|
292
|
+
Scenario: Using the 'eq' count filter
|
293
|
+
When the following query is executed:
|
294
|
+
"""
|
295
|
+
select name
|
296
|
+
from scenarios, outlines
|
297
|
+
with tc eq 3
|
298
|
+
"""
|
299
|
+
Then the following values are returned:
|
300
|
+
| name |
|
301
|
+
| Test 3 |
|
302
|
+
|
303
|
+
|
304
|
+
Scenario: Using multiple filters
|
305
|
+
When the following query is executed:
|
306
|
+
"""
|
307
|
+
select name
|
308
|
+
from scenarios
|
309
|
+
with tc eq 2
|
310
|
+
with lc gt 1
|
311
|
+
"""
|
312
|
+
Then the following values are returned:
|
313
|
+
| name |
|
314
|
+
| Test 2 |
|
315
|
+
|
316
|
+
Scenario: Using the 'with' clause multiple times
|
317
|
+
|
318
|
+
Behavior is the same as combining regular, block style filters but the syntax has to become more explicit.
|
319
|
+
|
320
|
+
When the following query is executed:
|
321
|
+
"""
|
322
|
+
select name
|
323
|
+
from scenarios
|
324
|
+
with tc(eq(2)),
|
325
|
+
lc(gt(1))
|
326
|
+
"""
|
327
|
+
Then the result is the same as the result of the following query:
|
328
|
+
"""
|
329
|
+
select name
|
330
|
+
from scenarios
|
331
|
+
with tc eq 2
|
332
|
+
with lc gt 1
|
333
|
+
"""
|
334
|
+
|
335
|
+
Scenario: Selectively filtering models
|
336
|
+
When the following query is executed:
|
337
|
+
"""
|
338
|
+
select name
|
339
|
+
from scenarios, features
|
340
|
+
with scenarios => lc(eq(1))
|
341
|
+
"""
|
342
|
+
Then the following values are returned:
|
343
|
+
| name |
|
344
|
+
| Test 1 |
|
345
|
+
| A test feature |
|
346
|
+
| A feature with lots of scenarios |
|
347
|
+
| A feature with lots of outlines |
|
348
|
+
| A feature with a mix of tests |
|
349
|
+
|
350
|
+
|
351
|
+
Scenario: Mixing targeted and blanket filters
|
352
|
+
When the following query is executed:
|
353
|
+
"""
|
354
|
+
select name
|
355
|
+
from scenarios, features
|
356
|
+
with name /test/i
|
357
|
+
with scenarios => tc(eq(0))
|
358
|
+
"""
|
359
|
+
Then the following values are returned:
|
360
|
+
| name |
|
361
|
+
| Test 4 |
|
362
|
+
| A test feature |
|
363
|
+
| A feature with a mix of tests |
|
364
|
+
|
365
|
+
Scenario: Using 'without' for negation
|
366
|
+
When the following query is executed:
|
367
|
+
"""
|
368
|
+
select name
|
369
|
+
from features
|
370
|
+
without ssoc lt 3
|
371
|
+
"""
|
372
|
+
Then the result is the same as the result of the following query:
|
373
|
+
"""
|
374
|
+
select name
|
375
|
+
from features
|
376
|
+
with ssoc gt 2
|
377
|
+
"""
|
378
|
+
|
379
|
+
Scenario: Mixing predefined filters and regular filters
|
380
|
+
When the following query is executed:
|
381
|
+
"""
|
382
|
+
select name
|
383
|
+
from scenarios, features
|
384
|
+
with { |element| element.name =~ /test/i }
|
385
|
+
with scenarios => tc(eq(0))
|
386
|
+
"""
|
387
|
+
Then the following values are returned:
|
388
|
+
| name |
|
389
|
+
| Test 4 |
|
390
|
+
| A test feature |
|
391
|
+
| A feature with a mix of tests |
|
392
|
+
|