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.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/lib/cql/dsl.rb +11 -1
  3. data/lib/cql/filters.rb +14 -1
  4. data/lib/cql/query.rb +5 -2
  5. data/lib/cql/repository.rb +1 -0
  6. data/lib/cql/version.rb +1 -1
  7. data/testing/cucumber/features/clauses/from_clause.feature +0 -8
  8. data/testing/cucumber/features/clauses/predefined_with_filters.feature +392 -0
  9. data/testing/cucumber/features/clauses/select_clause.feature +1 -5
  10. data/testing/cucumber/features/clauses/with_clause.feature +2 -164
  11. data/testing/cucumber/features/dsl.feature +0 -22
  12. data/testing/cucumber/step_definitions/verification_steps.rb +5 -6
  13. data/testing/gemfiles/cuke_modeler0.gemfile +9 -7
  14. data/testing/gemfiles/cuke_modeler1.gemfile +5 -7
  15. data/testing/gemfiles/cuke_modeler2.gemfile +33 -0
  16. data/testing/gemfiles/cuke_modeler3.gemfile +10 -0
  17. data/testing/helper_methods.rb +13 -0
  18. data/testing/model_helper.rb +28 -0
  19. data/testing/rspec/spec/clauses/as_clause_spec.rb +1 -0
  20. data/testing/rspec/spec/clauses/from_clause_spec.rb +146 -0
  21. data/testing/rspec/spec/clauses/select_clause_spec.rb +184 -0
  22. data/testing/rspec/spec/clauses/transform_clause_spec.rb +35 -0
  23. data/testing/rspec/spec/clauses/with_clause_spec.rb +84 -0
  24. data/testing/rspec/spec/clauses/without_clause_spec.rb +171 -0
  25. data/testing/rspec/spec/cql_spec.rb +31 -0
  26. data/testing/rspec/spec/dsl_spec.rb +3 -575
  27. data/testing/rspec/spec/filter_example_spec.rb +1 -1
  28. data/testing/rspec/spec/filter_feature_dsl_spec.rb +13 -13
  29. data/testing/rspec/spec/filter_sso_spec.rb +2 -2
  30. data/testing/rspec/spec/line_filterable_specs.rb +1 -1
  31. data/testing/rspec/spec/map_reduce_spec.rb +1 -1
  32. data/testing/rspec/spec/model_query_spec.rb +1 -1
  33. data/testing/rspec/spec/multiple_queries_spec.rb +1 -1
  34. data/testing/rspec/spec/name_filterable_specs.rb +1 -1
  35. data/testing/rspec/spec/predefined_filters_spec.rb +284 -0
  36. data/testing/rspec/spec/repository_spec.rb +3 -3
  37. data/testing/rspec/spec/select_feature_dsl_spec.rb +8 -8
  38. data/testing/rspec/spec/select_scen_outline_dsl_spec.rb +14 -14
  39. data/testing/rspec/spec/select_scenario_dsl_spec.rb +9 -9
  40. data/testing/rspec/spec/spec_helper.rb +7 -17
  41. metadata +67 -40
  42. data/testing/cucumber/support/transforms.rb +0 -3
@@ -50,7 +50,7 @@ describe "example filters (with)" do
50
50
  }
51
51
 
52
52
  it 'should filter by multiple filters' do
53
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/examples/filters/tag_count")
53
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/examples/filters/tag_count")
54
54
 
55
55
  result = gs.query do
56
56
  select name
@@ -5,7 +5,7 @@ describe "feature filters (with)" do
5
5
  describe 'scenario outline and scenario count functions (ssoc)' do
6
6
 
7
7
  it 'should filter based on ssoc_gt' do
8
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
8
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
9
9
 
10
10
  expected_results = {5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}]}
11
11
 
@@ -21,7 +21,7 @@ describe "feature filters (with)" do
21
21
  end
22
22
 
23
23
  it 'should filter based on ssoc_gte' do
24
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
24
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
25
25
 
26
26
  expected_results = {1 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
27
27
  5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
@@ -40,7 +40,7 @@ describe "feature filters (with)" do
40
40
  end
41
41
 
42
42
  it 'should filter based on ssoc_lt' do
43
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
43
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
44
44
 
45
45
  expected_results = {10 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
46
46
  9 => [{"name" => "f3_2_scenarios_3_so"}],
@@ -58,7 +58,7 @@ describe "feature filters (with)" do
58
58
  end
59
59
 
60
60
  it 'should filter based on ssoc_lte' do
61
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
61
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
62
62
 
63
63
  expected_results = {10 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
64
64
  9 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
@@ -81,7 +81,7 @@ describe "feature filters (with)" do
81
81
 
82
82
  describe 'scenario count functions (sc)' do
83
83
  it 'should filter based on sc_gt' do
84
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
84
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
85
85
 
86
86
  expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}]}
87
87
 
@@ -97,7 +97,7 @@ describe "feature filters (with)" do
97
97
  end
98
98
 
99
99
  it 'should filter based on sc_gte' do
100
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
100
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
101
101
 
102
102
  expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
103
103
  4 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}],
@@ -116,7 +116,7 @@ describe "feature filters (with)" do
116
116
  end
117
117
 
118
118
  it 'should filter based on sc_lt' do
119
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
119
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
120
120
 
121
121
  expected_results = {
122
122
  7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
@@ -135,7 +135,7 @@ describe "feature filters (with)" do
135
135
  end
136
136
 
137
137
  it 'should filter based on sc_lte' do
138
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
138
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
139
139
 
140
140
  expected_results = {7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
141
141
  5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
@@ -188,7 +188,7 @@ describe "feature filters (with)" do
188
188
 
189
189
  describe 'scenario outline count functions (soc)' do
190
190
  it 'should filter based on soc_gt' do
191
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
191
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
192
192
 
193
193
  expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
194
194
  5 => []}
@@ -205,7 +205,7 @@ describe "feature filters (with)" do
205
205
  end
206
206
 
207
207
  it 'should filter based on soc_gte' do
208
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
208
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
209
209
 
210
210
  expected_results = {2 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
211
211
  3 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f3_2_scenarios_3_so"}],
@@ -224,7 +224,7 @@ describe "feature filters (with)" do
224
224
  end
225
225
 
226
226
  it 'should filter based on soc_lt' do
227
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
227
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
228
228
 
229
229
  expected_results = {7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
230
230
  5 => [{"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
@@ -243,7 +243,7 @@ describe "feature filters (with)" do
243
243
  end
244
244
 
245
245
  it 'should filter based on soc_lte' do
246
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/combined/a")
246
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/combined/a")
247
247
 
248
248
  expected_results = {7 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
249
249
  5 => [{"name" => "f1_4_scenarios_5_so"}, {"name" => "f2_7_scenarios_2_so"}, {"name" => "f3_2_scenarios_3_so"}],
@@ -271,7 +271,7 @@ describe "feature filters (with)" do
271
271
 
272
272
 
273
273
  it 'should filter by multiple filters' do
274
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
274
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tagged_features")
275
275
 
276
276
  result = gs.query do
277
277
  select name
@@ -126,7 +126,7 @@ describe "scenario and outline filters (with)" do
126
126
  /will not be found/ => []}}}
127
127
 
128
128
  it 'should filter by multiple filters' do
129
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tag_count")
129
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/tag_count")
130
130
 
131
131
  result = gs.query do
132
132
  select name
@@ -139,7 +139,7 @@ describe "scenario and outline filters (with)" do
139
139
  end
140
140
 
141
141
  it 'should filter by multiple filters' do
142
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tag_count")
142
+ gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scen_outlines/filters/tag_count")
143
143
 
144
144
  result = gs.query do
145
145
  select name
@@ -38,7 +38,7 @@ shared_examples_for 'a line filterable target set' do |target_type, test_data|
38
38
  end
39
39
 
40
40
  it 'can only handle a string or regular expression' do
41
- gs = CQL::Repository.new(@feature_fixtures_directory)
41
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
42
42
 
43
43
  expect { gs.query do
44
44
  select name
@@ -7,7 +7,7 @@ describe "cql" do
7
7
  # it 'should find the physical files' do
8
8
  # skip("This is possibly no longer be needed")
9
9
  #
10
- # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
10
+ # gs = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/scenario/simple")
11
11
  # result = CQL::MapReduce.uri(gs.parsed_feature_files)
12
12
  #
13
13
  # expect(result[0]).to match(/simple\.feature/)
@@ -1,7 +1,7 @@
1
1
  require "#{File.dirname(__FILE__)}/spec_helper"
2
2
 
3
3
 
4
- describe 'a query enhanced model', :cuke_modeler_1x => true do
4
+ describe 'a query enhanced model', :unless => cuke_modeler?(0) do
5
5
 
6
6
  let(:clazz) { CukeModeler::Model }
7
7
  let(:model) { clazz.new }
@@ -6,7 +6,7 @@ describe "cql" do
6
6
  describe 'repo' do
7
7
  it 'should not change between queries' do
8
8
 
9
- repo = CQL::Repository.new("#{@feature_fixtures_directory}/got")
9
+ repo = CQL::Repository.new("#{CQL_FEATURE_FIXTURES_DIRECTORY}/got")
10
10
 
11
11
  before_dump = Marshal.dump(repo)
12
12
 
@@ -38,7 +38,7 @@ shared_examples_for 'a name filterable target set' do |target_type, test_data|
38
38
  end
39
39
 
40
40
  it 'can only handle a string or regular expression' do
41
- gs = CQL::Repository.new(@feature_fixtures_directory)
41
+ gs = CQL::Repository.new(CQL_FEATURE_FIXTURES_DIRECTORY)
42
42
 
43
43
  expect { gs.query do
44
44
  select name
@@ -0,0 +1,284 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+
4
+ describe "predefined 'with' filters" do
5
+
6
+ let(:nodule) { CQL::Dsl }
7
+ let(:dsl_enabled_object) { Object.new.extend(nodule) }
8
+
9
+
10
+ describe 'count filters' do
11
+
12
+ describe 'tag count' do
13
+
14
+ describe 'equality' do
15
+
16
+ it 'correctly filters features' do
17
+ feature_1 = CukeModeler::Feature.new('@tag
18
+ Feature: Feature with 1 tag')
19
+ feature_2 = CukeModeler::Feature.new('@tag @tag
20
+ Feature: Feature with 2 tags')
21
+ feature_3 = CukeModeler::Feature.new('@tag @tag @tag
22
+ Feature: Feature with 3 tags')
23
+ gs = CQL::Repository.new(directory_with(feature_1, feature_2, feature_3))
24
+
25
+ result = gs.query do
26
+ select name
27
+ from features
28
+ with tc eq 2
29
+ end
30
+
31
+ expect(result).to eq([{'name' => 'Feature with 2 tags'}])
32
+ end
33
+
34
+ it 'correctly filters scenarios' do
35
+ gherkin = 'Feature:
36
+
37
+ @tag
38
+ Scenario: Test with 1 tag
39
+
40
+ @tag @tag
41
+ Scenario: Test with 2 tags
42
+
43
+ @tag @tag @tag
44
+ Scenario: Test with 3 tags'
45
+ gs = CQL::Repository.new(CukeModeler::Feature.new(gherkin))
46
+
47
+ result = gs.query do
48
+ select name
49
+ from scenarios
50
+ with tc eq 2
51
+ end
52
+
53
+ expect(result).to eq([{'name' => 'Test with 2 tags'}])
54
+ end
55
+
56
+ it 'correctly filters outlines' do
57
+ gherkin = 'Feature:
58
+
59
+ @tag
60
+ Scenario Outline: Test with 1 tag
61
+ * a step
62
+
63
+ @tag @tag
64
+ Scenario Outline: Test with 2 tags
65
+ * a step
66
+
67
+ @tag @tag @tag
68
+ Scenario Outline: Test with 3 tags
69
+ * a step'
70
+ gs = CQL::Repository.new(CukeModeler::Feature.new(gherkin))
71
+
72
+ result = gs.query do
73
+ select name
74
+ from outlines
75
+ with tc eq 2
76
+ end
77
+
78
+ expect(result).to eq([{'name' => 'Test with 2 tags'}])
79
+ end
80
+
81
+ it 'correctly filters examples' do
82
+ gherkin = 'Feature:
83
+
84
+ Scenario Outline:
85
+ * a step
86
+
87
+ @tag
88
+ Examples: Example with 1 tag
89
+ | foo |
90
+ @tag @tag
91
+ Examples: Example with 2 tags
92
+ | foo |
93
+ @tag @tag @tag
94
+ Examples: Example with 3 tags
95
+ | foo |'
96
+ gs = CQL::Repository.new(CukeModeler::Feature.new(gherkin))
97
+
98
+ result = gs.query do
99
+ select name
100
+ from examples
101
+ with tc eq 2
102
+ end
103
+
104
+ expect(result).to eq([{'name' => 'Example with 2 tags'}])
105
+ end
106
+
107
+ end
108
+
109
+ end
110
+
111
+ describe 'line count' do
112
+
113
+ describe 'equality' do
114
+
115
+ it 'correctly filters backgrounds' do
116
+ feature_1 = CukeModeler::Feature.new('Feature:
117
+ Background: Background with 1 step
118
+ * a step')
119
+ feature_2 = CukeModeler::Feature.new('Feature:
120
+ Background: Background with 2 steps
121
+ * a step
122
+ * a step')
123
+ feature_3 = CukeModeler::Feature.new('Feature:
124
+ Background: Background with 3 steps
125
+ * a step
126
+ * a step
127
+ * a step')
128
+ gs = CQL::Repository.new(directory_with(feature_1, feature_2, feature_3))
129
+
130
+ result = gs.query do
131
+ select name
132
+ from backgrounds
133
+ with lc eq 2
134
+ end
135
+
136
+ expect(result).to eq([{'name' => 'Background with 2 steps'}])
137
+ end
138
+
139
+ it 'correctly filters scenarios' do
140
+ gherkin = 'Feature:
141
+ Scenario: Test with 1 step
142
+ * a step
143
+ Scenario: Test with 2 steps
144
+ * a step
145
+ * a step
146
+ Scenario: Test with 3 steps
147
+ * a step
148
+ * a step
149
+ * a step'
150
+ gs = CQL::Repository.new(CukeModeler::Feature.new(gherkin))
151
+
152
+ result = gs.query do
153
+ select name
154
+ from scenarios
155
+ with lc eq 2
156
+ end
157
+
158
+ expect(result).to eq([{'name' => 'Test with 2 steps'}])
159
+ end
160
+
161
+ it 'correctly filters outlines' do
162
+ gherkin = 'Feature:
163
+ Scenario Outline: Test with 1 step
164
+ * a step
165
+ Scenario Outline: Test with 2 steps
166
+ * a step
167
+ * a step
168
+ Scenario Outline: Test with 3 steps
169
+ * a step
170
+ * a step
171
+ * a step'
172
+ gs = CQL::Repository.new(CukeModeler::Feature.new(gherkin))
173
+
174
+ result = gs.query do
175
+ select name
176
+ from outlines
177
+ with lc eq 2
178
+ end
179
+
180
+ expect(result).to eq([{'name' => 'Test with 2 steps'}])
181
+ end
182
+
183
+ end
184
+
185
+ end
186
+
187
+ describe 'scenario count' do
188
+
189
+ describe 'equality' do
190
+
191
+ it 'correctly filters features' do
192
+ feature_1 = CukeModeler::Feature.new('Feature: Feature with 1 scenario
193
+ Scenario:')
194
+ feature_2 = CukeModeler::Feature.new('Feature: Feature with 2 scenarios
195
+ Scenario:
196
+ Scenario:')
197
+ feature_3 = CukeModeler::Feature.new('Feature: Feature with 3 scenarios
198
+ Scenario:
199
+ Scenario:
200
+ Scenario:')
201
+ gs = CQL::Repository.new(directory_with(feature_1, feature_2, feature_3))
202
+
203
+ result = gs.query do
204
+ select name
205
+ from features
206
+ with sc eq 2
207
+ end
208
+
209
+ expect(result).to eq([{'name' => 'Feature with 2 scenarios'}])
210
+ end
211
+
212
+ end
213
+
214
+ end
215
+
216
+ describe 'outline count' do
217
+
218
+ describe 'equality' do
219
+
220
+ it 'correctly filters features' do
221
+ feature_1 = CukeModeler::Feature.new('Feature: Feature with 1 outline
222
+ Scenario Outline:
223
+ * a step')
224
+ feature_2 = CukeModeler::Feature.new('Feature: Feature with 2 outlines
225
+ Scenario Outline:
226
+ * a step
227
+ Scenario Outline:
228
+ * a step')
229
+ feature_3 = CukeModeler::Feature.new('Feature: Feature with 3 outlines
230
+ Scenario Outline:
231
+ * a step
232
+ Scenario Outline:
233
+ * a step
234
+ Scenario Outline:
235
+ * a step')
236
+ gs = CQL::Repository.new(directory_with(feature_1, feature_2, feature_3))
237
+
238
+ result = gs.query do
239
+ select name
240
+ from features
241
+ with soc eq 2
242
+ end
243
+
244
+ expect(result).to eq([{'name' => 'Feature with 2 outlines'}])
245
+ end
246
+
247
+ end
248
+
249
+ end
250
+
251
+ describe 'scenario and outline count' do
252
+
253
+ describe 'equality' do
254
+
255
+ it 'correctly filters features' do
256
+ feature_1 = CukeModeler::Feature.new('Feature: Feature with 1 test
257
+ Scenario:')
258
+ feature_2 = CukeModeler::Feature.new('Feature: Feature with 2 tests
259
+ Scenario:
260
+ Scenario Outline:
261
+ * a step')
262
+ feature_3 = CukeModeler::Feature.new('Feature: Feature with 3 tests
263
+ Scenario:
264
+ Scenario Outline:
265
+ * a step
266
+ Scenario:')
267
+ gs = CQL::Repository.new(directory_with(feature_1, feature_2, feature_3))
268
+
269
+ result = gs.query do
270
+ select name
271
+ from features
272
+ with ssoc eq 2
273
+ end
274
+
275
+ expect(result).to eq([{'name' => 'Feature with 2 tests'}])
276
+ end
277
+
278
+ end
279
+
280
+ end
281
+
282
+ end
283
+
284
+ end