cql 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cql.rb +18 -11
  3. data/lib/cql/dsl.rb +14 -2
  4. data/lib/cql/filters.rb +12 -6
  5. data/lib/cql/map_reduce.rb +29 -11
  6. data/lib/cql/model_dsl.rb +18 -0
  7. data/lib/cql/queriable.rb +14 -0
  8. data/lib/cql/sso_filters.rb +3 -2
  9. data/lib/cql/version.rb +1 -1
  10. data/testing/cql_test_model.rb +42 -0
  11. data/testing/cucumber/features/clauses/as_clause.feature +136 -0
  12. data/testing/cucumber/features/clauses/from_clause.feature +126 -0
  13. data/testing/cucumber/features/clauses/select_clause.feature +117 -0
  14. data/testing/cucumber/features/clauses/transform_clause.feature +153 -0
  15. data/testing/cucumber/features/clauses/with_clause.feature +363 -0
  16. data/testing/cucumber/features/dsl.feature +77 -0
  17. data/testing/cucumber/features/model_querying.feature +18 -0
  18. data/testing/cucumber/features/repository.feature +23 -0
  19. data/testing/cucumber/step_definitions/query_steps.rb +7 -0
  20. data/testing/cucumber/step_definitions/setup_steps.rb +25 -0
  21. data/testing/cucumber/step_definitions/verification_steps.rb +78 -0
  22. data/testing/cucumber/support/env.rb +24 -0
  23. data/testing/cucumber/support/transforms.rb +3 -0
  24. data/testing/fixtures/features/combined/a/f1_4_scenarios_5_so.feature +59 -0
  25. data/testing/fixtures/features/combined/a/f2_7_scenarios_2_so.feature +43 -0
  26. data/testing/fixtures/features/combined/a/f3_2_scenarios_3_so.feature +30 -0
  27. data/testing/fixtures/features/combined/b/f1_1_tag.feature +6 -0
  28. data/testing/fixtures/features/combined/b/f2_2_tags.feature +6 -0
  29. data/testing/fixtures/features/combined/b/f3_3_tags.feature +6 -0
  30. data/testing/fixtures/features/examples/basic/test_with_scenarios.feature +15 -0
  31. data/testing/fixtures/features/examples/filters/tag_count/simple.feature +21 -0
  32. data/testing/fixtures/features/examples/filters/tag_count/simple2.feature +21 -0
  33. data/testing/fixtures/features/examples/filters/tags/simple.feature +34 -0
  34. data/testing/fixtures/features/examples/filters/tags2/simple.feature +34 -0
  35. data/testing/fixtures/features/examples/filters/tags2/simple2.feature +34 -0
  36. data/testing/fixtures/features/examples/multiple_examples/test_with_scenarios.feature +43 -0
  37. data/testing/fixtures/features/examples/name_filter/name.feature +19 -0
  38. data/testing/fixtures/features/got/Lannisters.feature +24 -0
  39. data/testing/fixtures/features/got/Starks.feature +18 -0
  40. data/testing/fixtures/features/scen_outlines/basic/test_with_scenarios.feature +15 -0
  41. data/testing/fixtures/features/scen_outlines/filters/tag_count/simple.feature +21 -0
  42. data/testing/fixtures/features/scen_outlines/filters/tag_count/simple2.feature +21 -0
  43. data/testing/fixtures/features/scen_outlines/filters/tags/simple.feature +34 -0
  44. data/testing/fixtures/features/scen_outlines/filters/tags2/simple.feature +34 -0
  45. data/testing/fixtures/features/scen_outlines/filters/tags2/simple2.feature +34 -0
  46. data/testing/fixtures/features/scen_outlines/line_count/simple.feature +12 -0
  47. data/testing/fixtures/features/scen_outlines/line_count/simple2.feature +16 -0
  48. data/testing/fixtures/features/scen_outlines/line_filter/ll.feature +13 -0
  49. data/testing/fixtures/features/scen_outlines/multiple_examples/test_with_scenarios.feature +43 -0
  50. data/testing/fixtures/features/scen_outlines/name_filter/name.feature +19 -0
  51. data/testing/fixtures/features/scenario/line_count/simple.feature +9 -0
  52. data/testing/fixtures/features/scenario/line_count/simple2.feature +12 -0
  53. data/testing/fixtures/features/scenario/line_filter/ll.feature +9 -0
  54. data/testing/fixtures/features/scenario/name_filter/name.feature +13 -0
  55. data/testing/fixtures/features/scenario/simple/simple.feature +8 -0
  56. data/testing/fixtures/features/scenario/simple/test.feature +9 -0
  57. data/testing/fixtures/features/scenario/simple/test2.feature +5 -0
  58. data/testing/fixtures/features/scenario/simple/test_full.feature +22 -0
  59. data/testing/fixtures/features/scenario/simple2/test_full.feature +23 -0
  60. data/testing/fixtures/features/scenario/table/simple.feature +11 -0
  61. data/testing/fixtures/features/scenario/tag_count/simple.feature +17 -0
  62. data/testing/fixtures/features/scenario/tag_count/simple2.feature +17 -0
  63. data/testing/fixtures/features/scenario/tagged_features/simple.feature +8 -0
  64. data/testing/fixtures/features/scenario/tagged_features/test.feature +10 -0
  65. data/testing/fixtures/features/scenario/tagged_features/test2.feature +6 -0
  66. data/testing/fixtures/features/scenario/tagged_features/test_full.feature +22 -0
  67. data/testing/fixtures/features/scenario/tags/simple.feature +24 -0
  68. data/testing/fixtures/features/scenario/tags2/simple.feature +24 -0
  69. data/testing/fixtures/features/scenario/tags2/simple2.feature +24 -0
  70. data/testing/fixtures/features/scenario/tags3/simple.feature +21 -0
  71. data/testing/gemfiles/cuke_modeler0.gemfile +30 -0
  72. data/testing/gemfiles/cuke_modeler1.gemfile +30 -0
  73. data/testing/rspec/spec/dsl_spec.rb +600 -0
  74. data/testing/rspec/spec/filter_example_spec.rb +65 -0
  75. data/testing/rspec/spec/filter_feature_dsl_spec.rb +286 -0
  76. data/testing/rspec/spec/filter_sso_spec.rb +202 -0
  77. data/testing/rspec/spec/line_count_filterable_specs.rb +74 -0
  78. data/testing/rspec/spec/line_filterable_specs.rb +52 -0
  79. data/testing/rspec/spec/map_reduce_spec.rb +135 -0
  80. data/testing/rspec/spec/model_query_spec.rb +49 -0
  81. data/testing/rspec/spec/multiple_queries_spec.rb +24 -0
  82. data/testing/rspec/spec/name_filterable_specs.rb +52 -0
  83. data/testing/rspec/spec/queriable_specs.rb +45 -0
  84. data/testing/rspec/spec/repository_spec.rb +82 -0
  85. data/testing/rspec/spec/select_feature_dsl_spec.rb +114 -0
  86. data/testing/rspec/spec/select_scen_outline_dsl_spec.rb +234 -0
  87. data/testing/rspec/spec/select_scenario_dsl_spec.rb +132 -0
  88. data/testing/rspec/spec/spec_helper.rb +42 -0
  89. data/testing/rspec/spec/tag_filterable_specs.rb +107 -0
  90. metadata +170 -5
@@ -0,0 +1,65 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+
4
+ describe "example filters (with)" do
5
+
6
+
7
+ it_behaves_like 'a name filterable target set', 'examples', {:exact_name => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/name_filter",
8
+ :expected_results => {'name1' => [{"name" => "name1"}]}},
9
+ :regexp => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/name_filter",
10
+ :expected_results => {/name/ => [{"name" => "name1"}, {"name" => "name2"}, {"name" => "name3"}],
11
+ /name1/ => [{"name" => "name1"}]}}
12
+ }
13
+
14
+ it_behaves_like 'a tag filterable target set', 'examples', {:single_tag => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/filters/tags",
15
+ :expected_results => {'@one' => [{'name' => 'Next'}, {'name' => 'Another'}]}},
16
+
17
+ :multiple_tags => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/filters/tags2",
18
+ :expected_results => {['@one', '@five'] => [{'name' => 'Next'}]}},
19
+
20
+ :tc_lt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/filters/tag_count",
21
+ :expected_results => {0 => [],
22
+ 1 => [],
23
+ 2 => [{"name" => "1 tag"}],
24
+ 3 => [{"name" => "1 tag"}, {"name" => "2 tags"}],
25
+ 4 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}],
26
+ 5 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}]}},
27
+
28
+ :tc_lte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/filters/tag_count",
29
+ :expected_results => {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
+ :tc_gt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/filters/tag_count",
37
+ :expected_results => {0 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
38
+ 1 => [{"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
39
+ 2 => [{"name" => "3 tags"}, {"name" => "4 tags"}],
40
+ 3 => [{"name" => "4 tags"}],
41
+ 4 => []}},
42
+
43
+ :tc_gte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/filters/tag_count",
44
+ :expected_results => {0 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
45
+ 1 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
46
+ 2 => [{"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
47
+ 3 => [{"name" => "3 tags"}, {"name" => "4 tags"}],
48
+ 4 => [{"name" => "4 tags"}],
49
+ 5 => []}}
50
+ }
51
+
52
+ it 'should filter by multiple filters' do
53
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/examples/filters/tag_count")
54
+
55
+ result = gs.query do
56
+ select name
57
+ from examples
58
+ with tc gt 1
59
+ with tc lt 3
60
+ end
61
+
62
+ expect(result).to eq([{"name" => "2 tags"}])
63
+ end
64
+
65
+ end
@@ -0,0 +1,286 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+
4
+ describe "feature filters (with)" do
5
+ describe 'scenario outline and scenario count functions (ssoc)' do
6
+
7
+ it 'should filter based on ssoc_gt' do
8
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
9
+
10
+ expected_results = {5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}]}
11
+
12
+ expected_results.each do |number, expected|
13
+ result = gs.query do
14
+ select name
15
+ from features
16
+ with ssoc gt number
17
+ end
18
+
19
+ expect(result).to match_array(expected)
20
+ end
21
+ end
22
+
23
+ it 'should filter based on ssoc_gte' do
24
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
25
+
26
+ expected_results = {1 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
27
+ 5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
28
+ 9 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}],
29
+ 10 => []}
30
+
31
+ expected_results.each do |number, expected|
32
+ result = gs.query do
33
+ select name
34
+ from features
35
+ with ssoc gte number
36
+ end
37
+
38
+ expect(result).to match_array(expected)
39
+ end
40
+ end
41
+
42
+ it 'should filter based on ssoc_lt' do
43
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
44
+
45
+ expected_results = {10 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
46
+ 9 => [{"name" => "f3_2_scenarios_3_so"}],
47
+ 3 => []}
48
+
49
+ expected_results.each do |number, expected|
50
+ result = gs.query do
51
+ select name
52
+ from features
53
+ with ssoc lt number
54
+ end
55
+
56
+ expect(result).to match_array(expected)
57
+ end
58
+ end
59
+
60
+ it 'should filter based on ssoc_lte' do
61
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
62
+
63
+ expected_results = {10 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
64
+ 9 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
65
+ 5 => [{"name" => "f3_2_scenarios_3_so"}],
66
+ 4 => []}
67
+
68
+ expected_results.each do |number, expected|
69
+ result = gs.query do
70
+ select name
71
+ from features
72
+ with ssoc lte number
73
+ end
74
+
75
+ expect(result).to match_array(expected)
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+
82
+ describe 'scenario count functions (sc)' do
83
+ it 'should filter based on sc_gt' do
84
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
85
+
86
+ expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}]}
87
+
88
+ expected_results.each do |number, expected|
89
+ result = gs.query do
90
+ select name
91
+ from features
92
+ with sc gt number
93
+ end
94
+
95
+ expect(result).to match_array(expected)
96
+ end
97
+ end
98
+
99
+ it 'should filter based on sc_gte' do
100
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
101
+
102
+ expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
103
+ 4 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}],
104
+ 3 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}],
105
+ 7 => [{"name" => "f2_7_scenarios_2_so"}]}
106
+
107
+ expected_results.each do |number, expected|
108
+ result = gs.query do
109
+ select name
110
+ from features
111
+ with sc gte number
112
+ end
113
+
114
+ expect(result).to match_array(expected)
115
+ end
116
+ end
117
+
118
+ it 'should filter based on sc_lt' do
119
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
120
+
121
+ expected_results = {
122
+ 7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
123
+ 5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
124
+ 4 => [{"name" => "f3_2_scenarios_3_so"}]}
125
+
126
+ expected_results.each do |number, expected|
127
+ result = gs.query do
128
+ select name
129
+ from features
130
+ with sc lt number
131
+ end
132
+
133
+ expect(result).to match_array(expected)
134
+ end
135
+ end
136
+
137
+ it 'should filter based on sc_lte' do
138
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
139
+
140
+ expected_results = {7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
141
+ 5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
142
+ 4 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}]}
143
+
144
+ expected_results.each do |number, expected|
145
+ result = gs.query do
146
+ select name
147
+ from features
148
+ with sc lte number
149
+ end
150
+
151
+ expect(result).to match_array(expected)
152
+ end
153
+ end
154
+ end
155
+
156
+ it_behaves_like 'a tag filterable target set', 'features', {:single_tag => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tagged_features",
157
+ :expected_results => {'@one' => [{"name" => "Test Feature"}, {"name" => "Test3 Feature"}],
158
+ '@two' => [{"name" => "Test2 Feature"}, {"name" => "Test3 Feature"}]}},
159
+ :multiple_tags => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tagged_features",
160
+ :expected_results => {['@one', '@two'] => [{"name" => "Test3 Feature"}]}},
161
+ :tc_lt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/b",
162
+ :expected_results => {0 => [],
163
+ 1 => [],
164
+ 2 => [{"name" => "f1_1_tag"}],
165
+ 3 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}],
166
+ 4 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}],
167
+ 5 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}]}},
168
+ :tc_lte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/b",
169
+ :expected_results => {0 => [],
170
+ 1 => [{"name" => "f1_1_tag"}],
171
+ 2 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}],
172
+ 3 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}],
173
+ 4 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}]}},
174
+ :tc_gt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/b",
175
+ :expected_results => {0 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}],
176
+ 1 => [{"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}],
177
+ 2 => [{"name" => "f3_3_tags"}],
178
+ 3 => [],
179
+ 4 => []}},
180
+ :tc_gte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/b",
181
+ :expected_results => {0 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}],
182
+ 1 => [{"name" => "f1_1_tag"}, {"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}],
183
+ 2 => [{"name" => "f2_2_tags"}, {"name" => "f3_3_tags"}],
184
+ 3 => [{"name" => "f3_3_tags"}],
185
+ 4 => [],
186
+ 5 => []}}
187
+ }
188
+
189
+ describe 'scenario outline count functions (soc)' do
190
+ it 'should filter based on soc_gt' do
191
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
192
+
193
+ expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
194
+ 5 => []}
195
+
196
+ expected_results.each do |number, expected|
197
+ result = gs.query do
198
+ select name
199
+ from features
200
+ with soc gt number
201
+ end
202
+
203
+ expect(result).to match_array(expected)
204
+ end
205
+ end
206
+
207
+ it 'should filter based on soc_gte' do
208
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
209
+
210
+ expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
211
+ 3 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
212
+ 4 => [{"name" => "f1_4_scenarios_5_so"}],
213
+ 7 => []}
214
+
215
+ expected_results.each do |number, expected|
216
+ result = gs.query do
217
+ select name
218
+ from features
219
+ with soc gte number
220
+ end
221
+
222
+ expect(result).to match_array(expected)
223
+ end
224
+ end
225
+
226
+ it 'should filter based on soc_lt' do
227
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
228
+
229
+ expected_results = {7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
230
+ 5 => [{"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
231
+ 4 => [{"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}]}
232
+
233
+
234
+ expected_results.each do |number, expected|
235
+ result = gs.query do
236
+ select name
237
+ from features
238
+ with soc lt number
239
+ end
240
+
241
+ expect(result).to match_array(expected)
242
+ end
243
+ end
244
+
245
+ it 'should filter based on soc_lte' do
246
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
247
+
248
+ expected_results = {7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
249
+ 5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
250
+ 4 => [{"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}]}
251
+
252
+
253
+ expected_results.each do |number, expected|
254
+ result = gs.query do
255
+ select name
256
+ from features
257
+ with soc lte number
258
+ end
259
+
260
+ expect(result).to match_array(expected)
261
+ end
262
+ end
263
+ end
264
+
265
+ it_behaves_like 'a name filterable target set', 'features', {:exact_name => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tagged_features",
266
+ :expected_results => {'Test2 Feature' => [{"name" => "Test2 Feature"}]}},
267
+ :regexp => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tagged_features",
268
+ :expected_results => {/Test2 Feature/ => [{"name" => "Test2 Feature"}],
269
+ /Feature/ => [{"name" => "Test Feature"}, {"name" => "Test2 Feature"}, {"name" => "Test3 Feature"}]}}
270
+ }
271
+
272
+
273
+ it 'should filter by multiple filters' do
274
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
275
+
276
+ result = gs.query do
277
+ select name
278
+ from features
279
+ with tags '@two'
280
+ with tags '@one'
281
+ end
282
+
283
+ expect(result).to eq([{"name" => "Test3 Feature"}])
284
+ end
285
+
286
+ end
@@ -0,0 +1,202 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+
4
+ describe "scenario and outline filters (with)" do
5
+
6
+
7
+ it_behaves_like 'a name filterable target set', 'scenarios', {:exact_name => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/name_filter",
8
+ :expected_results => {'name1' => [{"name" => "name1"}]}},
9
+ :regexp => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/name_filter",
10
+ :expected_results => {/name/ => [{"name" => "name1"}, {"name" => "name2"}, {"name" => "name3"}],
11
+ /name1/ => [{"name" => "name1"}]}}
12
+ }
13
+
14
+ it_behaves_like 'a tag filterable target set', 'scenarios', {:single_tag => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tags",
15
+ :expected_results => {'@one' => [{'name' => 'Next'}, {'name' => 'Another'}]}},
16
+
17
+ :multiple_tags => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tags2",
18
+ :expected_results => {['@one', '@five'] => [{'name' => 'Next'}]}},
19
+
20
+ :tc_lt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tag_count",
21
+ :expected_results => {0 => [],
22
+ 1 => [],
23
+ 2 => [{"name" => "1 tag"}],
24
+ 3 => [{"name" => "1 tag"}, {"name" => "2 tags"}],
25
+ 4 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}],
26
+ 5 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}]}},
27
+
28
+ :tc_lte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tag_count",
29
+ :expected_results => {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
+ :tc_gt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tag_count",
37
+ :expected_results => {0 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
38
+ 1 => [{"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
39
+ 2 => [{"name" => "3 tags"}, {"name" => "4 tags"}],
40
+ 3 => [{"name" => "4 tags"}],
41
+ 4 => []}},
42
+
43
+ :tc_gte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tag_count",
44
+ :expected_results => {0 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
45
+ 1 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
46
+ 2 => [{"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
47
+ 3 => [{"name" => "3 tags"}, {"name" => "4 tags"}],
48
+ 4 => [{"name" => "4 tags"}],
49
+ 5 => []}}
50
+ }
51
+
52
+ it_behaves_like 'a tag filterable target set', 'outlines', {:single_tag => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/filters/tags",
53
+ :expected_results => {'@one' => [{'name' => 'Next'}, {'name' => 'Another'}]}},
54
+
55
+ :multiple_tags => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/filters/tags2",
56
+ :expected_results => {['@one', '@five'] => [{'name' => 'Next'}]}},
57
+
58
+ :tc_lt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/filters/tag_count",
59
+ :expected_results => {0 => [],
60
+ 1 => [],
61
+ 2 => [{"name" => "1 tag"}],
62
+ 3 => [{"name" => "1 tag"}, {"name" => "2 tags"}],
63
+ 4 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}],
64
+ 5 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}]}},
65
+
66
+ :tc_lte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/filters/tag_count",
67
+ :expected_results => {0 => [],
68
+ 1 => [{"name" => "1 tag"}],
69
+ 2 => [{"name" => "1 tag"}, {"name" => "2 tags"}],
70
+ 3 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}],
71
+ 4 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
72
+ 5 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}]}},
73
+
74
+ :tc_gt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/filters/tag_count",
75
+ :expected_results => {0 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
76
+ 1 => [{"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
77
+ 2 => [{"name" => "3 tags"}, {"name" => "4 tags"}],
78
+ 3 => [{"name" => "4 tags"}],
79
+ 4 => []}},
80
+
81
+ :tc_gte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/filters/tag_count",
82
+ :expected_results => {0 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
83
+ 1 => [{"name" => "1 tag"}, {"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
84
+ 2 => [{"name" => "2 tags"}, {"name" => "3 tags"}, {"name" => "4 tags"}],
85
+ 3 => [{"name" => "3 tags"}, {"name" => "4 tags"}],
86
+ 4 => [{"name" => "4 tags"}],
87
+ 5 => []}}
88
+ }
89
+
90
+ it_behaves_like 'a line count filterable target set', 'scenarios', {:lc_lt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/line_count",
91
+ :expected_results => {0 => [],
92
+ 1 => [],
93
+ 2 => [{"name" => "1 line"}],
94
+ 3 => [{"name" => "1 line"}, {"name" => "2 lines"}],
95
+ 4 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}],
96
+ 5 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}]}},
97
+ :lc_lte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/line_count",
98
+ :expected_results => {0 => [],
99
+ 1 => [{"name" => "1 line"}],
100
+ 2 => [{"name" => "1 line"}, {"name" => "2 lines"}],
101
+ 3 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}],
102
+ 4 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
103
+ 5 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}]}},
104
+ :lc_gt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/line_count",
105
+ :expected_results => {0 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
106
+ 1 => [{"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
107
+ 2 => [{"name" => "3 lines"}, {"name" => "4 lines"}],
108
+ 3 => [{"name" => "4 lines"}],
109
+ 4 => []}},
110
+ :lc_gte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/line_count",
111
+ :expected_results => {0 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
112
+ 1 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
113
+ 2 => [{"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
114
+ 3 => [{"name" => "3 lines"}, {"name" => "4 lines"}],
115
+ 4 => [{"name" => "4 lines"}],
116
+ 5 => []}}}
117
+
118
+
119
+ it_behaves_like 'a line filterable target set', 'scenarios', {:exact_line => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/line_filter",
120
+ :expected_results => {'all match' => [{"name" => "sc1"}, {"name" => "sc2"}],
121
+ 'green eggs and ham' => [{"name" => "sc1"}],
122
+ 'no match' => []}},
123
+ :regexp => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/line_filter",
124
+ :expected_results => {/all/ => [{"name" => "sc1"}, {"name" => "sc2"}],
125
+ /green/ => [{"name" => "sc1"}],
126
+ /will not be found/ => []}}}
127
+
128
+ it 'should filter by multiple filters' do
129
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tag_count")
130
+
131
+ result = gs.query do
132
+ select name
133
+ from scenarios
134
+ with tc gt 1
135
+ with tc lt 3
136
+ end
137
+
138
+ expect(result).to eq([{"name" => "2 tags"}])
139
+ end
140
+
141
+ it 'should filter by multiple filters' do
142
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tag_count")
143
+
144
+ result = gs.query do
145
+ select name
146
+ from outlines
147
+ with tc gt 1
148
+ with tc lt 3
149
+ end
150
+
151
+ expect(result).to eq([{"name" => "2 tags"}])
152
+ end
153
+
154
+
155
+ it_behaves_like 'a line count filterable target set', 'outlines', {:lc_lt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/line_count",
156
+ :expected_results => {0 => [],
157
+ 1 => [],
158
+ 2 => [{"name" => "1 line"}],
159
+ 3 => [{"name" => "1 line"}, {"name" => "2 lines"}],
160
+ 4 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}],
161
+ 5 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}]}},
162
+ :lc_lte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/line_count",
163
+ :expected_results => {0 => [],
164
+ 1 => [{"name" => "1 line"}],
165
+ 2 => [{"name" => "1 line"}, {"name" => "2 lines"}],
166
+ 3 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}],
167
+ 4 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
168
+ 5 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}]}},
169
+ :lc_gt => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/line_count",
170
+ :expected_results => {0 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
171
+ 1 => [{"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
172
+ 2 => [{"name" => "3 lines"}, {"name" => "4 lines"}],
173
+ 3 => [{"name" => "4 lines"}],
174
+ 4 => []}},
175
+ :lc_gte => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/line_count",
176
+ :expected_results => {0 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
177
+ 1 => [{"name" => "1 line"}, {"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
178
+ 2 => [{"name" => "2 lines"}, {"name" => "3 lines"}, {"name" => "4 lines"}],
179
+ 3 => [{"name" => "3 lines"}, {"name" => "4 lines"}],
180
+ 4 => [{"name" => "4 lines"}],
181
+ 5 => []}}}
182
+
183
+
184
+ it_behaves_like 'a line filterable target set', 'outlines', {:exact_line => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/line_filter",
185
+ :expected_results => {'all match' => [{"name" => "sc1"}, {"name" => "sc2"}],
186
+ 'green eggs and ham' => [{"name" => "sc1"}],
187
+ 'no match' => []}},
188
+ :regexp => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/line_filter",
189
+ :expected_results => {/all/ => [{"name" => "sc1"}, {"name" => "sc2"}],
190
+ /green/ => [{"name" => "sc1"}],
191
+ /will not be found/ => []}}}
192
+
193
+
194
+ it_behaves_like 'a name filterable target set', 'outlines', {:exact_name => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/name_filter",
195
+ :expected_results => {'name1' => [{"name" => "name1"}]}},
196
+ :regexp => {:fixture_location => "#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/name_filter",
197
+ :expected_results => {/name/ => [{"name" => "name1"}, {"name" => "name2"}, {"name" => "name3"}],
198
+ /name1/ => [{"name" => "name1"}]}}
199
+ }
200
+
201
+ # # Example count
202
+ end