cql 1.4.2 → 1.5.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.
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
@@ -0,0 +1,35 @@
1
+ require "#{File.dirname(__FILE__)}/../spec_helper"
2
+
3
+
4
+ describe 'an object that uses the DSL' do
5
+
6
+
7
+ let(:nodule) { CQL::Dsl }
8
+ let(:dsl_enabled_object) { Object.new.extend(nodule) }
9
+
10
+
11
+ describe "transform" do
12
+
13
+ describe "multiple targets" do
14
+
15
+ it 'does not apply more transforms than have been declared' do
16
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/simple")
17
+
18
+ results = gs.query do
19
+ select :self, :self, :self
20
+ as thing1, thing2, thing3
21
+ from scenarios
22
+ transform :self => lambda { |thing1| 1 }
23
+ transform :self => lambda { |thing2| 2 }
24
+ end
25
+
26
+ expect(results.first).to include('thing1' => 1, 'thing2' => 2)
27
+ expect(results.first).to_not include('thing3' => 1)
28
+ expect(results.first).to_not include('thing3' => 2)
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,84 @@
1
+ require "#{File.dirname(__FILE__)}/../spec_helper"
2
+
3
+
4
+ describe 'an object that uses the DSL' do
5
+
6
+ let(:nodule) { CQL::Dsl }
7
+ let(:dsl_enabled_object) { Object.new.extend(nodule) }
8
+
9
+
10
+ describe 'with' do
11
+
12
+ it 'knows how to filter selections with certain qualities' do
13
+ expect(dsl_enabled_object).to respond_to(:with)
14
+ end
15
+
16
+
17
+ describe 'targeted' do
18
+
19
+ it 'can handle predefined filters' do
20
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
21
+
22
+ expect {
23
+ gs.query do
24
+ select name
25
+ from features, scenarios, outlines
26
+ with scenarios => name(/test/)
27
+ end
28
+ }.to_not raise_error
29
+ end
30
+
31
+ it 'can handle a block filter' do
32
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
33
+
34
+ expect {
35
+ gs.query do
36
+ select name
37
+ from features, scenarios, outlines
38
+ with scenarios => lambda { |scenario| true }
39
+ end
40
+ }.to_not raise_error
41
+ end
42
+
43
+ it 'correctly filters with a targeted block' do
44
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
45
+
46
+ result = gs.query do
47
+ select name
48
+ from scenarios
49
+ with scenarios => lambda { |scenario| scenario.name =~ /king of/ }
50
+ end
51
+
52
+ expect(result).to eq([{'name' => 'The king of kings'}])
53
+ end
54
+
55
+ it 'can handle shorthand targets' do
56
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
57
+
58
+ expect {
59
+ gs.query do
60
+ select name
61
+ from features, scenarios, outlines
62
+ with scenarios => name(/test/)
63
+ end
64
+ }.to_not raise_error
65
+ end
66
+
67
+ it 'can handle multiple targets' do
68
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
69
+
70
+ expect {
71
+ gs.query do
72
+ select name
73
+ from features, scenarios, outlines
74
+ with scenarios => lambda { |scenario| true },
75
+ outlines => lambda { |outline| true }
76
+ end
77
+ }.to_not raise_error
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+
84
+ end
@@ -0,0 +1,171 @@
1
+ require "#{File.dirname(__FILE__)}/../spec_helper"
2
+
3
+
4
+ describe 'an object that uses the DSL' do
5
+
6
+ let(:nodule) { CQL::Dsl }
7
+ let(:dsl_enabled_object) { Object.new.extend(nodule) }
8
+
9
+
10
+ describe 'without' do
11
+
12
+ it 'knows how to filter selections without certain qualities' do
13
+ expect(dsl_enabled_object).to respond_to(:without)
14
+ end
15
+
16
+ it 'correctly negates a block filter' do
17
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/simple")
18
+
19
+ negated_result = gs.query do
20
+ select name
21
+ from scenarios
22
+ with { |scenario| !(scenario.source_line == 3) }
23
+ end
24
+
25
+ without_result = gs.query do
26
+ select name
27
+ from scenarios
28
+ without { |scenario| scenario.source_line == 3 }
29
+ end
30
+
31
+ expect(without_result).to eq(negated_result)
32
+ end
33
+
34
+ it 'correctly negates a targeted filter' do
35
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/simple")
36
+
37
+ negated_result = gs.query do
38
+ select :model
39
+ from features, scenarios
40
+ with scenarios => lambda { |scenario| false }
41
+ end
42
+
43
+ without_result = gs.query do
44
+ select :model
45
+ from features, scenarios
46
+ without scenarios => lambda { |scenario| true }
47
+ end
48
+
49
+ expect(without_result).to eq(negated_result)
50
+ end
51
+
52
+
53
+ describe 'negating predefined filters' do
54
+
55
+ it 'correctly negates a tag count filter' do
56
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tags2")
57
+
58
+ negated_result = gs.query do
59
+ select :model
60
+ from scenarios
61
+ with tc lt 2
62
+ end
63
+
64
+ without_result = gs.query do
65
+ select :model
66
+ from scenarios
67
+ without tc gt 1
68
+ end
69
+
70
+ expect(without_result).to eq(negated_result)
71
+ end
72
+
73
+ it 'correctly negates a name filter' do
74
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/name_filter")
75
+
76
+ negated_result = gs.query do
77
+ select :model
78
+ from scenarios
79
+ with name /name[^1]/
80
+ end
81
+
82
+ without_result = gs.query do
83
+ select :model
84
+ from scenarios
85
+ without name /name1/
86
+ end
87
+
88
+ expect(without_result).to eq(negated_result)
89
+ end
90
+
91
+ it 'correctly negates a line filter' do
92
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/line_filter")
93
+
94
+ negated_result = gs.query do
95
+ select name
96
+ from scenarios
97
+ with line 'green eggs and ham'
98
+ end
99
+
100
+ without_result = gs.query do
101
+ select name
102
+ from scenarios
103
+ without line 'some other phrase'
104
+ end
105
+
106
+ expect(without_result).to eq(negated_result)
107
+ end
108
+
109
+ it 'correctly negates a tag filter' do
110
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tags3")
111
+
112
+ negated_result = gs.query do
113
+ select :model
114
+ from scenarios
115
+ with tags '@one'
116
+ end
117
+
118
+ without_result = gs.query do
119
+ select :model
120
+ from scenarios
121
+ without tags '@two'
122
+ end
123
+
124
+ expect(without_result).to eq(negated_result)
125
+ end
126
+
127
+ end
128
+
129
+ it 'correctly negates a targeted, predefined filter' do
130
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
131
+
132
+ negated_result = gs.query do
133
+ select :model
134
+ from :all
135
+ with scenarios => name(/(?!test)/)
136
+ end
137
+
138
+ without_result = gs.query do
139
+ select :model
140
+ from :all
141
+ without scenarios => name(/test/)
142
+ end
143
+
144
+ expect(without_result).to eq(negated_result)
145
+ end
146
+
147
+ it 'correctly negates multiple filters' do
148
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
149
+
150
+ negated_result = gs.query do
151
+ select :model
152
+ from :all
153
+ with scenarios => lambda { |scenario| false },
154
+ outlines => lambda { |outline| false }
155
+ with { |model| !model.is_a?(CukeModeler::Example) }
156
+ end
157
+
158
+ without_result = gs.query do
159
+ select :model
160
+ from :all
161
+ without scenarios => lambda { |scenario| true },
162
+ outlines => lambda { |outline| true }
163
+ without { |model| model.is_a?(CukeModeler::Example) }
164
+ end
165
+
166
+ expect(without_result).to eq(negated_result)
167
+ end
168
+
169
+ end
170
+
171
+ end
@@ -11,7 +11,7 @@ describe 'an object that uses the DSL' do
11
11
  describe 'invalid query structure' do
12
12
 
13
13
  it "will complain if no 'from' clause is specified" do
14
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
14
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/simple")
15
15
 
16
16
  expect {
17
17
  gs.query do
@@ -22,7 +22,7 @@ describe 'an object that uses the DSL' do
22
22
  end
23
23
 
24
24
  it "will complain if no 'select' clause is specified" do
25
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
25
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/simple")
26
26
 
27
27
  expect {
28
28
  gs.query do
@@ -39,7 +39,7 @@ describe 'an object that uses the DSL' do
39
39
  it 'handles intermixed clauses' do
40
40
  # Clause ordering doesn't matter as long as any given type of clause is ordered correctly with respect to its multiple uses
41
41
 
42
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
42
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/simple")
43
43
 
44
44
  results = gs.query do
45
45
  with { |scenario| scenario.name =~ /slurping/ }
@@ -59,576 +59,4 @@ describe 'an object that uses the DSL' do
59
59
 
60
60
  end
61
61
 
62
-
63
- describe "select" do
64
-
65
- it 'knows how to select attributes' do
66
- expect(dsl_enabled_object).to respond_to(:select)
67
- end
68
-
69
- it 'selects one or more attributes' do
70
- expect(dsl_enabled_object.method(:select).arity).to eq(-1)
71
- end
72
-
73
- it 'correctly selects a single attribute from a model' do
74
- model = CukeModeler::CqlTestModel.new
75
- model.attribute_1 = 'foo'
76
-
77
- repo = CQL::Repository.new(model)
78
-
79
- result = repo.query do
80
- select attribute_1
81
- from cql_test_model
82
- end
83
-
84
-
85
- expect(result).to eq([{'attribute_1' => 'foo'}])
86
- end
87
-
88
- it 'correctly selects multiple attributes from a model' do
89
- model = CukeModeler::CqlTestModel.new
90
- model.attribute_1 = 'foo'
91
- model.attribute_2 = 'bar'
92
-
93
- repo = CQL::Repository.new(model)
94
-
95
- result = repo.query do
96
- select attribute_1, attribute_2
97
- from cql_test_model
98
- end
99
-
100
-
101
- expect(result).to eq([{'attribute_1' => 'foo',
102
- 'attribute_2' => 'bar'}])
103
- end
104
-
105
-
106
- describe 'special attributes' do
107
-
108
- it 'understands the :model attribute' do
109
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
110
-
111
- expect { gs.query do
112
- select :model
113
- from features
114
- end
115
- }.to_not raise_error
116
- end
117
-
118
- it 'interprets :model in the same manner that it interprets :self' do
119
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
120
-
121
- self_result = gs.query do
122
- select :self
123
- from features
124
- end
125
-
126
- model_result = gs.query do
127
- select :model
128
- from features
129
- end
130
-
131
- # Only checking the values of the results because they will have different :model/:self keys
132
- expect(model_result.collect { |result| result.values }).to eq(self_result.collect { |result| result.values })
133
- end
134
-
135
- it 'complains if an unknown special attribute is queried' do
136
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
137
-
138
- expect {
139
- gs.query do
140
- select :foo
141
- from scenarios
142
- end
143
- }.to raise_error(ArgumentError, ":foo is not a valid attribute for selection.")
144
- end
145
-
146
- it 'uses the :self attribute by default' do
147
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
148
-
149
- default_result = gs.query do
150
- select
151
- from features
152
- end
153
-
154
- self_result = gs.query do
155
- select :self
156
- from features
157
- end
158
-
159
- expect(self_result).to eq(default_result)
160
- end
161
-
162
- end
163
-
164
-
165
- it 'complains if an unknown normal attribute is queried' do
166
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
167
-
168
- expect {
169
- gs.query do
170
- select steps
171
- from features
172
- end
173
- }.to raise_error(ArgumentError, "'steps' is not a valid attribute for selection from a 'CukeModeler::Feature'.")
174
- end
175
-
176
-
177
- describe "multiple selections" do
178
-
179
- it 'can freely mix empty selections and attribute selections' do
180
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
181
-
182
- base_result = gs.query do
183
- select :self
184
- select name
185
- select :self
186
- as 'foo', 'bar', 'baz'
187
- from scenarios
188
- end
189
-
190
-
191
- expect(
192
- gs.query do
193
- select
194
- select name
195
- select
196
- as 'foo', 'bar', 'baz'
197
- from scenarios
198
- end
199
- ).to eq(base_result)
200
- end
201
-
202
- end
203
-
204
-
205
- describe 'duplicate selections' do
206
-
207
- let(:warning_message) { "Multiple selections made without using an 'as' clause\n" }
208
-
209
- it "warns if the same attribute is selected more than once without an 'as' clause being used" do
210
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
211
-
212
- expect {
213
- gs.query do
214
- select :model, :model, :model
215
- from :all
216
- end
217
- }.to output(warning_message).to_stderr
218
- end
219
-
220
- it "does not warn if the same attribute is selected more than once and an 'as' clause is used" do
221
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
222
-
223
- expect {
224
- gs.query do
225
- select :model, :model, :model
226
- # Usage of the clause is sufficient. Not going to try and count the mappings or anything like that.
227
- as foo
228
- from :all
229
- end
230
- }.to_not output(warning_message).to_stderr
231
- end
232
-
233
- end
234
-
235
- end
236
-
237
- describe "from" do
238
-
239
- it 'knows from what to select attributes' do
240
- expect(dsl_enabled_object).to respond_to(:from)
241
- end
242
-
243
- it 'selects from one or more things' do
244
- expect(dsl_enabled_object.method(:from).arity).to eq(-1)
245
- end
246
-
247
- it "can handle an empty 'from' clause" do
248
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
249
-
250
- result = gs.query do
251
- select name
252
- from
253
- end
254
-
255
- expect(result).to eq([])
256
- end
257
-
258
- describe "multiple targets" do
259
-
260
- it 'raises an exception for inapplicable attributes' do
261
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
262
-
263
- expect {
264
- gs.query do
265
- select name, steps
266
- from features
267
- from scenarios
268
- end
269
- }.to raise_error(ArgumentError)
270
- end
271
-
272
- end
273
-
274
- describe 'shorthand' do
275
-
276
- it 'should consider an exact match over a pluralization' do
277
- plural_class_model = CukeModeler::CqlTestModels.new
278
- singular_class_model = CukeModeler::CqlTestModel.new
279
-
280
- plural_class_model.attribute_1 = 'plural'
281
- singular_class_model.attribute_1 = 'singular'
282
- plural_class_model.children << singular_class_model
283
-
284
- repo = CQL::Repository.new(plural_class_model)
285
-
286
- result = repo.query do
287
- select attribute_1
288
- from cql_test_model
289
- end
290
-
291
- expect(result.first['attribute_1']).to eq('singular')
292
- end
293
-
294
- it 'raises an exception if the shorthand form of a class cannot be mapped to a real class' do
295
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
296
-
297
- expect {
298
- gs.query do
299
- select name
300
- from not_a_real_class
301
- end
302
- }.to raise_error(ArgumentError, "Class 'CukeModeler::NotARealClass' does not exist")
303
-
304
- end
305
-
306
- it 'can freely mix shorthand and long-form names' do
307
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
308
-
309
- # All long-form
310
- base_result = gs.query do
311
- select name
312
- from CukeModeler::Scenario, CukeModeler::Feature
313
- end
314
-
315
- # All shorthand
316
- expect(
317
- gs.query do
318
- select name
319
- from scenarios, features
320
- end
321
- ).to eq(base_result)
322
-
323
- # A mix of both
324
- expect(
325
- gs.query do
326
- select name
327
- from CukeModeler::Scenario, features
328
- end
329
- ).to eq(base_result)
330
- end
331
-
332
- end
333
-
334
-
335
- describe 'special scopes' do
336
-
337
- it 'understands the :all scope' do
338
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
339
-
340
- expect { gs.query do
341
- select :model
342
- from :all
343
- end
344
- }.to_not raise_error
345
- end
346
-
347
- it 'queries from all models when scoped to :all' do
348
- model_1 = CukeModeler::CqlTestModel.new
349
- model_2 = CukeModeler::CqlTestModel.new
350
- model_3 = CukeModeler::CqlTestModel.new
351
-
352
- model_1.children << model_2
353
- model_1.children << model_3
354
-
355
- repo = CQL::Repository.new(model_1)
356
-
357
- result = repo.query do
358
- select :model
359
- from :all
360
- end
361
-
362
- expect(result).to match_array([{:model => model_1},
363
- {:model => model_2},
364
- {:model => model_3}])
365
- end
366
-
367
- end
368
-
369
- end
370
-
371
- describe "transform" do
372
-
373
- describe "multiple targets" do
374
-
375
- it 'does not apply more transforms than have been declared' do
376
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
377
-
378
- results = gs.query do
379
- select :self, :self, :self
380
- as thing1, thing2, thing3
381
- from scenarios
382
- transform :self => lambda { |thing1| 1 }
383
- transform :self => lambda { |thing2| 2 }
384
- end
385
-
386
- expect(results.first).to include('thing1' => 1, 'thing2' => 2)
387
- expect(results.first).to_not include('thing3' => 1)
388
- expect(results.first).to_not include('thing3' => 2)
389
- end
390
-
391
- end
392
-
393
- end
394
-
395
-
396
- describe 'with' do
397
-
398
- it 'knows how to filter selections with certain qualities' do
399
- expect(dsl_enabled_object).to respond_to(:with)
400
- end
401
-
402
-
403
- describe 'targeted' do
404
-
405
- it 'can handle predefined filters' do
406
- gs = CQL::Repository.new(@feature_fixtures_directory)
407
-
408
- expect {
409
- gs.query do
410
- select name
411
- from features, scenarios, outlines
412
- with scenarios => name(/test/)
413
- end
414
- }.to_not raise_error
415
- end
416
-
417
- it 'can handle a block filter' do
418
- gs = CQL::Repository.new(@feature_fixtures_directory)
419
-
420
- expect {
421
- gs.query do
422
- select name
423
- from features, scenarios, outlines
424
- with scenarios => lambda { |scenario| true }
425
- end
426
- }.to_not raise_error
427
- end
428
-
429
- it 'correctly filters with a targeted block' do
430
- gs = CQL::Repository.new(@feature_fixtures_directory)
431
-
432
- result = gs.query do
433
- select name
434
- from scenarios
435
- with scenarios => lambda { |scenario| scenario.name =~ /king of/ }
436
- end
437
-
438
- expect(result).to eq([{'name' => 'The king of kings'}])
439
- end
440
-
441
- it 'can handle shorthand targets' do
442
- gs = CQL::Repository.new(@feature_fixtures_directory)
443
-
444
- expect {
445
- gs.query do
446
- select name
447
- from features, scenarios, outlines
448
- with scenarios => name(/test/)
449
- end
450
- }.to_not raise_error
451
- end
452
-
453
- it 'can handle multiple targets' do
454
- gs = CQL::Repository.new(@feature_fixtures_directory)
455
-
456
- expect {
457
- gs.query do
458
- select name
459
- from features, scenarios, outlines
460
- with scenarios => lambda { |scenario| true },
461
- outlines => lambda { |outline| true }
462
- end
463
- }.to_not raise_error
464
- end
465
-
466
- end
467
-
468
- end
469
-
470
-
471
- describe 'without' do
472
-
473
- it 'knows how to filter selections without certain qualities' do
474
- expect(dsl_enabled_object).to respond_to(:without)
475
- end
476
-
477
- it 'correctly negates a block filter' do
478
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
479
-
480
- negated_result = gs.query do
481
- select name
482
- from scenarios
483
- with { |scenario| !(scenario.source_line == 3) }
484
- end
485
-
486
- without_result = gs.query do
487
- select name
488
- from scenarios
489
- without { |scenario| scenario.source_line == 3 }
490
- end
491
-
492
- expect(without_result).to eq(negated_result)
493
- end
494
-
495
- it 'correctly negates a targeted filter' do
496
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
497
-
498
- negated_result = gs.query do
499
- select :model
500
- from features, scenarios
501
- with scenarios => lambda { |scenario| false }
502
- end
503
-
504
- without_result = gs.query do
505
- select :model
506
- from features, scenarios
507
- without scenarios => lambda { |scenario| true }
508
- end
509
-
510
- # puts "1: #{negated_result}"
511
-
512
-
513
- expect(without_result).to eq(negated_result)
514
- end
515
-
516
-
517
- describe 'negating predefined filters' do
518
-
519
- it 'correctly negates a tag count filter' do
520
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tags2")
521
-
522
- negated_result = gs.query do
523
- select :model
524
- from scenarios
525
- with tc lt 2
526
- end
527
-
528
- without_result = gs.query do
529
- select :model
530
- from scenarios
531
- without tc gt 1
532
- end
533
-
534
- expect(without_result).to eq(negated_result)
535
- end
536
-
537
- it 'correctly negates a name filter' do
538
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/name_filter")
539
-
540
- negated_result = gs.query do
541
- select :model
542
- from scenarios
543
- with name /name[^1]/
544
- end
545
-
546
- without_result = gs.query do
547
- select :model
548
- from scenarios
549
- without name /name1/
550
- end
551
-
552
- expect(without_result).to eq(negated_result)
553
- end
554
-
555
- it 'correctly negates a line filter' do
556
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/line_filter")
557
-
558
- negated_result = gs.query do
559
- select name
560
- from scenarios
561
- with line 'green eggs and ham'
562
- end
563
-
564
- without_result = gs.query do
565
- select name
566
- from scenarios
567
- without line 'some other phrase'
568
- end
569
-
570
- end
571
-
572
- it 'correctly negates a tag filter' do
573
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tags3")
574
-
575
- negated_result = gs.query do
576
- select :model
577
- from scenarios
578
- with tags '@one'
579
- end
580
-
581
- without_result = gs.query do
582
- select :model
583
- from scenarios
584
- without tags '@two'
585
- end
586
-
587
- expect(without_result).to eq(negated_result)
588
- end
589
-
590
- end
591
-
592
- it 'correctly negates a targeted, predefined filter' do
593
- gs = CQL::Repository.new(@feature_fixtures_directory)
594
-
595
- negated_result = gs.query do
596
- select :model
597
- from :all
598
- with scenarios => name(/(?!test)/)
599
- end
600
-
601
- without_result = gs.query do
602
- select :model
603
- from :all
604
- without scenarios => name(/test/)
605
- end
606
-
607
- expect(without_result).to eq(negated_result)
608
- end
609
-
610
- it 'correctly negates multiple filters' do
611
- gs = CQL::Repository.new(@feature_fixtures_directory)
612
-
613
- negated_result = gs.query do
614
- select :model
615
- from :all
616
- with scenarios => lambda { |scenario| false },
617
- outlines => lambda { |outline| false }
618
- with { |model| !model.is_a?(CukeModeler::Example) }
619
- end
620
-
621
- without_result = gs.query do
622
- select :model
623
- from :all
624
- without scenarios => lambda { |scenario| true },
625
- outlines => lambda { |outline| true }
626
- without { |model| model.is_a?(CukeModeler::Example) }
627
- end
628
-
629
- expect(without_result).to eq(negated_result)
630
- end
631
-
632
- end
633
-
634
62
  end