cql 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cql/dsl.rb +5 -0
  3. data/lib/cql/version.rb +1 -1
  4. data/testing/cucumber/features/clauses/from_clause.feature +0 -8
  5. data/testing/cucumber/features/clauses/predefined_with_filters.feature +392 -0
  6. data/testing/cucumber/features/clauses/select_clause.feature +1 -5
  7. data/testing/cucumber/features/clauses/with_clause.feature +2 -164
  8. data/testing/cucumber/features/dsl.feature +0 -22
  9. data/testing/cucumber/step_definitions/verification_steps.rb +5 -6
  10. data/testing/model_helper.rb +28 -0
  11. data/testing/rspec/spec/clauses/as_clause_spec.rb +1 -0
  12. data/testing/rspec/spec/clauses/from_clause_spec.rb +146 -0
  13. data/testing/rspec/spec/clauses/select_clause_spec.rb +184 -0
  14. data/testing/rspec/spec/clauses/transform_clause_spec.rb +35 -0
  15. data/testing/rspec/spec/clauses/with_clause_spec.rb +84 -0
  16. data/testing/rspec/spec/clauses/without_clause_spec.rb +171 -0
  17. data/testing/rspec/spec/dsl_spec.rb +3 -575
  18. data/testing/rspec/spec/filter_example_spec.rb +1 -1
  19. data/testing/rspec/spec/filter_feature_dsl_spec.rb +13 -13
  20. data/testing/rspec/spec/filter_sso_spec.rb +2 -2
  21. data/testing/rspec/spec/line_filterable_specs.rb +1 -1
  22. data/testing/rspec/spec/map_reduce_spec.rb +1 -1
  23. data/testing/rspec/spec/multiple_queries_spec.rb +1 -1
  24. data/testing/rspec/spec/name_filterable_specs.rb +1 -1
  25. data/testing/rspec/spec/predefined_filters_spec.rb +284 -0
  26. data/testing/rspec/spec/repository_spec.rb +3 -3
  27. data/testing/rspec/spec/select_feature_dsl_spec.rb +8 -8
  28. data/testing/rspec/spec/select_scen_outline_dsl_spec.rb +14 -14
  29. data/testing/rspec/spec/select_scenario_dsl_spec.rb +9 -9
  30. data/testing/rspec/spec/spec_helper.rb +3 -13
  31. metadata +21 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 480c8624435a5cb099bdff3beed45bd86cf8e885
4
- data.tar.gz: 9dac6f20b35222fbdf438ea06e1f4e1e7aba111b
3
+ metadata.gz: c1a6431920afce8b5bb22168816f947c7754873d
4
+ data.tar.gz: 52a8f8287a9ae24f702ccbd7f511689a058ee962
5
5
  SHA512:
6
- metadata.gz: 459be59da7ad0eb4d0fbd2f25eef00890c054e5a694f5f8f8406f7cc7474602d527ffb63de68c903bb9aef271336ee317484b5dce620c4f67b2c0d2e70fa5128
7
- data.tar.gz: 29eacad72952a06a4395c9675979c32d243408b564f59070cf5adda1e264783122922e1cf248c5e1b980b93e9bfdb7328eaeda0ed5c9d7cae36c6df65403f6d0
6
+ metadata.gz: e86ebe5acdb55af2cb9bf1d9012e5a3046ccfd7d45a9c402b03e710e1f0f8f7289b10ab12b28d8ac4306fdaacb666d4001e793560b6064aa736050a5b44857dc
7
+ data.tar.gz: e60182bd6a14971947a91a1a5a364835665a8ee2764a4eab5e1708834379e51a9d370593dce21b91be3f549a813a8b506172142fbc96b26d32105defeb396fb6
@@ -134,6 +134,11 @@ module CQL
134
134
  Comparison.new '<=', amount
135
135
  end
136
136
 
137
+ # Adds an *eq* filter operator to the query. See the corresponding Cucumber documentation for details.
138
+ def eq amount
139
+ Comparison.new '==', amount
140
+ end
141
+
137
142
  # Adds a *tags* filter to the query. See the corresponding Cucumber documentation for details.
138
143
  def tags *tags
139
144
  return "tags" if tags.size == 0
@@ -1,4 +1,4 @@
1
1
  module CQL
2
2
  # The current version of the gem
3
- VERSION = '1.4.2'
3
+ VERSION = '1.5.0'
4
4
  end
@@ -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
+
@@ -92,7 +92,7 @@ Feature: 'select' clause
92
92
  from scenarios
93
93
  """
94
94
 
95
- Scenario: Repetitive selection
95
+ Scenario: Using the 'select' clause multiple times
96
96
  When the following query is executed:
97
97
  """
98
98
  select name
@@ -116,7 +116,3 @@ Feature: 'select' clause
116
116
  select :self
117
117
  from scenarios
118
118
  """
119
-
120
- # Commented out so that they aren't picked up by Relish
121
- # @wip
122
- # Scenario: Can select from all types of model