cql 1.3.0 → 1.4.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 +4 -4
- data/lib/cql.rb +1 -0
- data/lib/cql/version.rb +1 -1
- data/testing/cucumber/features/clauses/select_clause.feature +5 -1
- data/testing/cucumber/features/clauses/transform_clause.feature +6 -2
- data/testing/cucumber/features/clauses/with_clause.feature +6 -7
- data/testing/cucumber/step_definitions/setup_steps.rb +18 -0
- data/testing/cucumber/step_definitions/verification_steps.rb +11 -7
- data/testing/gemfiles/cuke_modeler0.gemfile +4 -0
- data/testing/gemfiles/cuke_modeler1.gemfile +4 -0
- data/testing/rspec/spec/dsl_spec.rb +34 -0
- data/testing/rspec/spec/line_filterable_specs.rb +1 -1
- data/testing/rspec/spec/name_filterable_specs.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe541449ce515566bd3a3483b42f2260829a03e1
|
4
|
+
data.tar.gz: 846f80e853bef0ba8d441187370ce948e6cca50b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f5bb7cb738155ad68f98b877d4889be5f57b69adec5c37804307aa47d29bde11c7819e3a883994e85ff3b903f636a542a575668b1cac9b299068244e3b08df6
|
7
|
+
data.tar.gz: ee4e8bf2dee1d7aeb0128c65fe3001c1d21c97290b6668384d044de2066880de687a2398040616f8f000eefb6d4aed1ff269a975ae2c8f51e6769ac7364063f6
|
data/lib/cql.rb
CHANGED
@@ -37,6 +37,7 @@ module CQL
|
|
37
37
|
raise(ArgumentError, "A query must specify a 'select' clause") unless @what
|
38
38
|
raise(ArgumentError, "A query must specify a 'from' clause") unless @from
|
39
39
|
|
40
|
+
warn("Multiple selections made without using an 'as' clause") unless @name_transforms || (@what.count == @what.uniq.count)
|
40
41
|
|
41
42
|
# Gather relevant objects from root object and filters
|
42
43
|
@data = CQL::MapReduce.gather_objects(@data, @from, @filters)
|
data/lib/cql/version.rb
CHANGED
@@ -59,13 +59,17 @@ Feature: 'select' clause
|
|
59
59
|
| Test 2 | 7 |
|
60
60
|
|
61
61
|
Scenario: Selection of the same attribute multiple times
|
62
|
+
|
63
|
+
Note: Duplicate attribute selection should be combined with an 'as' clause in order to ensure that later attribute selections do not override earlier selections of the same attribute.
|
64
|
+
|
62
65
|
When the following query is executed:
|
63
66
|
"""
|
64
67
|
select name, name
|
68
|
+
as name1, name2
|
65
69
|
from scenarios
|
66
70
|
"""
|
67
71
|
Then the following values are returned:
|
68
|
-
|
|
72
|
+
| name1 | name2 |
|
69
73
|
| Test 1 | Test 1 |
|
70
74
|
| Test 2 | Test 2 |
|
71
75
|
|
@@ -124,30 +124,34 @@ Feature: 'transform' clause
|
|
124
124
|
|
125
125
|
Scenario: Transforming duplicate attributes
|
126
126
|
|
127
|
+
Reminder: Duplicate attribute selection should be used in conjunction with the 'as' clause.
|
128
|
+
|
127
129
|
Sometimes you may want to select the same attribute multiple times and perform multiple different transformations on it. This can be done with both set transforming and selective transforming.
|
128
130
|
|
129
131
|
When the following query is executed:
|
130
132
|
"""
|
131
133
|
select name, tags, name
|
134
|
+
as name1, tags, name2
|
132
135
|
transform lambda { |name| name.upcase },
|
133
136
|
lambda { |tags| 9 },
|
134
137
|
lambda { |name| name.downcase }
|
135
138
|
from scenarios, outlines
|
136
139
|
"""
|
137
140
|
Then the following values are returned:
|
138
|
-
|
|
141
|
+
| name1 | tags | name2 |
|
139
142
|
| TEST 1 | 9 | test 1 |
|
140
143
|
| TEST 2 | 9 | test 2 |
|
141
144
|
| TEST 3 | 9 | test 3 |
|
142
145
|
When the following query is executed:
|
143
146
|
"""
|
144
147
|
select name, source_line, name
|
148
|
+
as name1, source_line, name2
|
145
149
|
transform name => lambda { |name| name.upcase }
|
146
150
|
transform name => lambda { |name| name.downcase }
|
147
151
|
from scenarios, outlines
|
148
152
|
"""
|
149
153
|
Then the following values are returned:
|
150
|
-
|
|
154
|
+
| name1 | source_line | name2 |
|
151
155
|
| TEST 1 | 3 | test 1 |
|
152
156
|
| TEST 2 | 7 | test 2 |
|
153
157
|
| TEST 3 | 10 | test 3 |
|
@@ -43,8 +43,8 @@ Feature: 'with' clause
|
|
43
43
|
|
44
44
|
|
45
45
|
Background: A sample Cucumber suite
|
46
|
-
Given a
|
47
|
-
And
|
46
|
+
Given a repository to query
|
47
|
+
And the following feature has been modeled in the repository:
|
48
48
|
"""
|
49
49
|
Feature: A test feature
|
50
50
|
|
@@ -67,7 +67,7 @@ Feature: 'with' clause
|
|
67
67
|
| param |
|
68
68
|
| value |
|
69
69
|
"""
|
70
|
-
And
|
70
|
+
And the following feature has been modeled in the repository:
|
71
71
|
"""
|
72
72
|
Feature: A feature with lots of scenarios
|
73
73
|
|
@@ -80,7 +80,7 @@ Feature: 'with' clause
|
|
80
80
|
Scenario: 3
|
81
81
|
* different steps
|
82
82
|
"""
|
83
|
-
And
|
83
|
+
And the following feature has been modeled in the repository:
|
84
84
|
"""
|
85
85
|
Feature: A feature with lots of outlines
|
86
86
|
|
@@ -102,7 +102,7 @@ Feature: 'with' clause
|
|
102
102
|
| param |
|
103
103
|
| value |
|
104
104
|
"""
|
105
|
-
And
|
105
|
+
And the following feature has been modeled in the repository:
|
106
106
|
"""
|
107
107
|
Feature: A feature with a mix of tests
|
108
108
|
|
@@ -115,7 +115,6 @@ Feature: 'with' clause
|
|
115
115
|
| param |
|
116
116
|
| value |
|
117
117
|
"""
|
118
|
-
And a repository is made from "test_directory"
|
119
118
|
|
120
119
|
|
121
120
|
Scenario: Using 'with' to limit the objects from which to return attributes
|
@@ -165,10 +164,10 @@ Feature: 'with' clause
|
|
165
164
|
Then the following values are returned:
|
166
165
|
| name |
|
167
166
|
| A test feature |
|
167
|
+
| Test 1 |
|
168
168
|
| A feature with lots of scenarios |
|
169
169
|
| A feature with lots of outlines |
|
170
170
|
| A feature with a mix of tests |
|
171
|
-
| Test 1 |
|
172
171
|
|
173
172
|
Scenario: Using the 'with' clause multiple times
|
174
173
|
When the following query is executed:
|
@@ -23,3 +23,21 @@ Given(/^the models provided by CukeModeler$/) do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
Given(/^a repository to query$/) do
|
28
|
+
@root_directory_model = CukeModeler::Directory.new
|
29
|
+
@repository = CQL::Repository.new(@root_directory_model)
|
30
|
+
end
|
31
|
+
|
32
|
+
And(/^the following feature has been modeled in the repository:$/) do |text|
|
33
|
+
file_model = CukeModeler::FeatureFile.new
|
34
|
+
|
35
|
+
# CukeModeler::FeatureFile had a different interface in 0.x
|
36
|
+
if file_model.respond_to?(:feature=)
|
37
|
+
file_model.feature = CukeModeler::Feature.new(text)
|
38
|
+
else
|
39
|
+
file_model.features << CukeModeler::Feature.new(text)
|
40
|
+
end
|
41
|
+
|
42
|
+
@root_directory_model.feature_files << file_model
|
43
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
Then(/^the following values are returned:$/) do |values|
|
2
|
+
expected_keys = values.raw.first
|
2
3
|
expected_results = values.hashes
|
3
|
-
expected_results.each { |result| result['source_line'] = result['source_line'].to_i if result['source_line'] }
|
4
|
-
expected_results.each { |result| result['scenario_line'] = result['scenario_line'].to_i if result['scenario_line'] }
|
5
|
-
expected_results.each { |result| result['tags'] = eval(result['tags']) if result['tags'] }
|
6
|
-
expected_results.each { |result| result['scenario_tags'] = eval(result['scenario_tags']) if result['scenario_tags'] }
|
7
4
|
|
8
5
|
expected_results.each do |result|
|
9
|
-
result.each_pair { |key, value| result[key] = value.
|
6
|
+
result.each_pair { |key, value| result[key] = value.to_i if value =~ /^\d+$/ }
|
10
7
|
end
|
11
8
|
|
12
|
-
|
9
|
+
|
10
|
+
@query_results.each_with_index do |result, index|
|
11
|
+
# Key order doesn't matter and Ruby 1.8.7 does not retain hash key ordering, so sorting them for consistency
|
12
|
+
expect(result.keys.sort).to eq(expected_keys.sort)
|
13
|
+
expect(result).to eq(expected_results[index])
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
# Then(/^all of them can be queried for additional information$/) do
|
@@ -45,8 +47,10 @@ Then(/^the following code executes without error:$/) do |code_text|
|
|
45
47
|
end
|
46
48
|
|
47
49
|
Then(/^all of them can be queried$/) do |code_text|
|
50
|
+
original_text = code_text
|
51
|
+
|
48
52
|
@available_model_classes.each do |clazz|
|
49
|
-
code_text.gsub
|
53
|
+
code_text = original_text.gsub('<model_class>', clazz.to_s)
|
50
54
|
|
51
55
|
expect(clazz.new).to respond_to(:query)
|
52
56
|
|
@@ -20,6 +20,10 @@ if RUBY_VERSION =~ /^1\./
|
|
20
20
|
gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
|
21
21
|
gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
|
22
22
|
gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
|
23
|
+
|
24
|
+
if RbConfig::CONFIG['host_os'].downcase =~ /mswin|msys|mingw32/
|
25
|
+
gem 'ffi', '< 1.9.15' # The 'ffi' gem, for Windows, requires Ruby 2.x on/after this version
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
if RUBY_VERSION =~ /^2\.[23456789]/
|
@@ -20,6 +20,10 @@ if RUBY_VERSION =~ /^1\./
|
|
20
20
|
gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
|
21
21
|
gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
|
22
22
|
gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
|
23
|
+
|
24
|
+
if RbConfig::CONFIG['host_os'].downcase =~ /mswin|msys|mingw32/
|
25
|
+
gem 'ffi', '< 1.9.15' # The 'ffi' gem, for Windows, requires Ruby 2.x on/after this version
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
if RUBY_VERSION =~ /^2\.[23456789]/
|
@@ -183,6 +183,7 @@ describe 'an object that uses the DSL' do
|
|
183
183
|
select :self
|
184
184
|
select name
|
185
185
|
select :self
|
186
|
+
as 'foo', 'bar', 'baz'
|
186
187
|
from scenarios
|
187
188
|
end
|
188
189
|
|
@@ -192,12 +193,45 @@ describe 'an object that uses the DSL' do
|
|
192
193
|
select
|
193
194
|
select name
|
194
195
|
select
|
196
|
+
as 'foo', 'bar', 'baz'
|
195
197
|
from scenarios
|
196
198
|
end
|
197
199
|
).to eq(base_result)
|
198
200
|
end
|
199
201
|
|
200
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
|
+
|
201
235
|
end
|
202
236
|
|
203
237
|
describe "from" do
|
@@ -44,7 +44,7 @@ shared_examples_for 'a line filterable target set' do |target_type, test_data|
|
|
44
44
|
select name
|
45
45
|
from scenarios
|
46
46
|
with line 7
|
47
|
-
end }.to raise_error(ArgumentError,
|
47
|
+
end }.to raise_error(ArgumentError, /^Can only match a String or Regexp. Got (?:Fixnum|Integer)\.$/)
|
48
48
|
|
49
49
|
end
|
50
50
|
|
@@ -44,7 +44,7 @@ shared_examples_for 'a name filterable target set' do |target_type, test_data|
|
|
44
44
|
select name
|
45
45
|
from scenarios
|
46
46
|
with name 7
|
47
|
-
end }.to raise_error(ArgumentError,
|
47
|
+
end }.to raise_error(ArgumentError, /^Can only match a String or Regexp. Got (?:Fixnum|Integer)\.$/)
|
48
48
|
|
49
49
|
end
|
50
50
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kessler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cuke_modeler
|
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
263
|
version: '0'
|
264
264
|
requirements: []
|
265
265
|
rubyforge_project:
|
266
|
-
rubygems_version: 2.
|
266
|
+
rubygems_version: 2.5.2
|
267
267
|
signing_key:
|
268
268
|
specification_version: 4
|
269
269
|
summary: A gem providing functionality to query a Cucumber test suite.
|