cql 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6805bf349ee0cbb1c9f38d2cad8c4b753454e08
4
+ data.tar.gz: e7a3dce28a0236ef2423f3d7827353ae2e6c0b77
5
+ SHA512:
6
+ metadata.gz: ecbf137679cd1cb1f402d543c5177e776950d1a68d36741cdf984743430961c990028fcf6ec416dbdd6583199d431413ba98ad20918f3ec6a90fc17e1e8e43fc
7
+ data.tar.gz: 72d5f4d09e184a38fd745b9e22346167b9441e6393942c2906b9e5a8bd56ca171d762961466f300b9e767a511f3b67b43fb76a7ca4cee7e89162faee46d923c2
data/lib/cql/filters.rb CHANGED
@@ -7,8 +7,12 @@ module CQL
7
7
  @tags = tags
8
8
  end
9
9
 
10
- def has_tags?(object, tags)
11
- tags.all? { |tag| object.tags.include?(tag) }
10
+ def has_tags?(object, target_tags)
11
+ target_tags.all? { |target_tag|
12
+ tags = object.tags
13
+ tags = tags.collect { |tag| tag.name } unless Gem.loaded_specs['cuke_modeler'].version.version[/^0/]
14
+ tags.include?(target_tag)
15
+ }
12
16
  end
13
17
 
14
18
  def execute objects
@@ -63,8 +63,10 @@ module CQL
63
63
  def collect_all_in(targeted_classes, current_object, accumulated_objects)
64
64
  accumulated_objects << current_object if targeted_classes.any? { |targeted_class| current_object.is_a?(targeted_class) }
65
65
 
66
- if current_object.respond_to?(:contains)
67
- current_object.contains.each do |child_object|
66
+ method_for_children = Gem.loaded_specs['cuke_modeler'].version.version[/^0/] ? :contains : :children
67
+
68
+ if current_object.respond_to?(method_for_children)
69
+ current_object.send(method_for_children).each do |child_object|
68
70
  collect_all_in(targeted_classes, child_object, accumulated_objects)
69
71
  end
70
72
  end
@@ -14,8 +14,10 @@ module CQL
14
14
  class LineFilter < ContentMatchFilter
15
15
 
16
16
  def execute(input)
17
+ method_for_text = Gem.loaded_specs['cuke_modeler'].version.version[/^0/] ? :base : :text
18
+
17
19
  input.find_all do |tests|
18
- raw_step_lines = tests.steps.map { |step| step.base }
20
+ raw_step_lines = tests.steps.map { |step| step.send(method_for_text) }
19
21
 
20
22
  content_match?(raw_step_lines)
21
23
  end
data/lib/cql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CQL
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/spec/dsl_spec.rb CHANGED
@@ -37,7 +37,7 @@ describe 'dsl' do
37
37
  gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
38
38
 
39
39
  results = gs.query do
40
- with { |thing| thing.tags.include?('@one') }
40
+ with { |scenario| scenario.name =~ /slurping/ }
41
41
  as thing1
42
42
  transform :self => lambda { |thing1| 1 }
43
43
  select :self
@@ -57,6 +57,37 @@ describe 'dsl' do
57
57
 
58
58
  describe "select" do
59
59
 
60
+ it 'correctly selects a single attribute from a model' do
61
+ model = CukeModeler::CqlTestModel.new
62
+ model.attribute_1 = 'foo'
63
+
64
+ repo = CQL::Repository.new(model)
65
+
66
+ result = repo.query do
67
+ select attribute_1
68
+ from cql_test_models
69
+ end
70
+
71
+
72
+ expect(result).to eq([{'attribute_1' => 'foo'}])
73
+ end
74
+
75
+ it 'correctly selects multiple attributes from a model' do
76
+ model = CukeModeler::CqlTestModel.new
77
+ model.attribute_1 = 'foo'
78
+ model.attribute_2 = 'bar'
79
+
80
+ repo = CQL::Repository.new(model)
81
+
82
+ result = repo.query do
83
+ select attribute_1, attribute_2
84
+ from cql_test_models
85
+ end
86
+
87
+
88
+ expect(result).to eq([{'attribute_1' => 'foo',
89
+ 'attribute_2' => 'bar'}])
90
+ end
60
91
 
61
92
  it 'complains if an unknown special attribute is queried' do
62
93
  gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
@@ -98,6 +129,17 @@ describe 'dsl' do
98
129
 
99
130
  describe "from" do
100
131
 
132
+ it "can handle an empty 'from' clause" do
133
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
134
+
135
+ result = gs.query do
136
+ select name
137
+ from
138
+ end
139
+
140
+ expect(result).to eq([])
141
+ end
142
+
101
143
  describe "multiple targets" do
102
144
 
103
145
  it 'raises an exception for inapplicable attributes' do
@@ -110,7 +152,6 @@ describe 'dsl' do
110
152
  from scenarios
111
153
  end
112
154
  }.to raise_error
113
-
114
155
  end
115
156
 
116
157
  end
@@ -15,16 +15,16 @@ describe "select" do
15
15
  {"name" => "Test2 Feature"}, {"name" => "Test3 Feature"}])
16
16
  end
17
17
 
18
- it 'should return descriptions from features' do
19
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
20
-
21
- result = gs.query do
22
- select description_text
23
- from features
24
- end
25
-
26
- expect(result).to eq([{"description_text" => "The cat in the hat"}])
27
- end
18
+ # it 'should return descriptions from features' do
19
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
20
+ #
21
+ # result = gs.query do
22
+ # select description_text
23
+ # from features
24
+ # end
25
+ #
26
+ # expect(result).to eq([{"description_text" => "The cat in the hat"}])
27
+ # end
28
28
 
29
29
  it 'should return paths from from feature files' do
30
30
  repo_path = "#{@feature_fixtures_directory}/scenario/simple"
@@ -41,34 +41,34 @@ describe "select" do
41
41
  {'path' => "#{repo_path}/test_full.feature"}])
42
42
  end
43
43
 
44
- it 'should return tags from features' do
45
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
46
-
47
- result = gs.query do
48
- select tags
49
- from features
50
- end
51
-
52
- expect(result).to match_array([{"tags" => []},
53
- {"tags" => ["@one"]},
54
- {"tags" => ["@two"]},
55
- {"tags" => ["@one", "@two"]}])
56
- end
57
-
58
-
59
- it 'should return multiple things from features' do
60
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
61
-
62
- result = gs.query do
63
- select name, tags
64
- from features
65
- end
66
-
67
- expect(result).to match_array([{"name" => "Simple", "tags" => []},
68
- {"name" => "Test Feature", "tags" => ["@one"]},
69
- {"name" => "Test2 Feature", "tags" => ["@two"]},
70
- {"name" => "Test3 Feature", "tags" => ["@one", "@two"]}])
71
- end
44
+ # it 'should return tags from features' do
45
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
46
+ #
47
+ # result = gs.query do
48
+ # select tags
49
+ # from features
50
+ # end
51
+ #
52
+ # expect(result).to match_array([{"tags" => []},
53
+ # {"tags" => ["@one"]},
54
+ # {"tags" => ["@two"]},
55
+ # {"tags" => ["@one", "@two"]}])
56
+ # end
57
+ #
58
+ #
59
+ # it 'should return multiple things from features' do
60
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
61
+ #
62
+ # result = gs.query do
63
+ # select name, tags
64
+ # from features
65
+ # end
66
+ #
67
+ # expect(result).to match_array([{"name" => "Simple", "tags" => []},
68
+ # {"name" => "Test Feature", "tags" => ["@one"]},
69
+ # {"name" => "Test2 Feature", "tags" => ["@two"]},
70
+ # {"name" => "Test3 Feature", "tags" => ["@one", "@two"]}])
71
+ # end
72
72
 
73
73
  it 'should return things from multiple feature files' do
74
74
  gr = CQL::Repository.new("#{@feature_fixtures_directory}/combined/b")
@@ -96,18 +96,18 @@ describe "select" do
96
96
  {"name" => "f3_3_tags"}])
97
97
  end
98
98
 
99
- it 'should return ids from features' do
100
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
101
-
102
- result = gs.query do
103
- select raw_element
104
- as 'id'
105
- transform 'raw_element' => lambda { |element| element['id'] }
106
- from features
107
- end
108
-
109
- expect(result).to eq([{"id" => "test3-feature"}])
110
- end
99
+ # it 'should return ids from features' do
100
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
101
+ #
102
+ # result = gs.query do
103
+ # select raw_element
104
+ # as 'id'
105
+ # transform 'raw_element' => lambda { |element| element['id'] }
106
+ # from features
107
+ # end
108
+ #
109
+ # expect(result).to eq([{"id" => "test3-feature"}])
110
+ # end
111
111
 
112
112
  end
113
113
  end
@@ -3,36 +3,37 @@ require 'spec_helper'
3
3
  describe "select" do
4
4
  describe 'from scenario_outlines' do
5
5
 
6
- it 'should return tags from scenario outlines' do
7
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
8
-
9
- result = gs.query do
10
- select tags
11
- from outlines
12
- end
13
-
14
- expect(result).to match_array([{"tags" => ["@two"]},
15
- {"tags" => ["@one"]},
16
- {"tags" => []},
17
- {"tags" => ["@two"]},
18
- {"tags" => ["@one"]},
19
- {"tags" => ["@two", "@four"]},
20
- {"tags" => ["@one", "@five"]},
21
- {"tags" => []},
22
- {"tags" => ["@two"]},
23
- {"tags" => ["@one"]}])
24
- end
25
-
26
- it 'should return descriptions from scenario outlines' do
27
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
28
-
29
- result = gs.query do
30
- select description_text
31
- from outlines
32
- end
33
-
34
- expect(result).to eq([{"description_text" => ""}, {"description_text" => "\nOutline description."}])
35
- end
6
+ # it 'should return tags from scenario outlines' do
7
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
8
+ #
9
+ # result = gs.query do
10
+ # select tags
11
+ # from outlines
12
+ # end
13
+ #
14
+ # expect(result).to match_array([{"tags" => ["@two"]},
15
+ # {"tags" => ["@one"]},
16
+ # {"tags" => []},
17
+ # {"tags" => ["@two"]},
18
+ # {"tags" => ["@one"]},
19
+ # {"tags" => ["@two", "@four"]},
20
+ # {"tags" => ["@one", "@five"]},
21
+ # {"tags" => []},
22
+ # {"tags" => ["@two"]},
23
+ # {"tags" => ["@one"]}])
24
+ # end
25
+ #
26
+ # it 'should return descriptions from scenario outlines' do
27
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
28
+ #
29
+ # result = gs.query do
30
+ # select description_text
31
+ # from outlines
32
+ # end
33
+ #
34
+ # expect(result).to eq([{"description_text" => ""}, {"description_text" => "\nOutline description."}])
35
+ # end
36
+ #
36
37
 
37
38
  it 'should return lines from scenario outlines' do
38
39
  gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
@@ -56,70 +57,70 @@ describe "select" do
56
57
  expect(result).to eq([{"name" => "An Outline"}])
57
58
  end
58
59
 
59
- it 'should return types from scenario outlines' do
60
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
61
-
62
- result = gs.query do
63
- select raw_element
64
- as 'type'
65
- transform 'raw_element' => lambda { |element| element['type'] }
66
- from outlines
67
- end
68
-
69
- expect(result).to eq([{"type" => "scenario_outline"}])
70
- end
71
-
72
- it 'should return step lines from scenario outlines' do
73
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
74
-
75
- result = gs.query do
76
- select raw_element
77
- as step_lines
78
- transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
79
- from outlines
80
- end
81
-
82
- expect(result).to eq([{"step_lines" => ["Given something happend", "Then I expect something else"]}])
83
- end
84
-
85
- it 'should return ids from scenario outlines' do
86
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
87
-
88
- result = gs.query do
89
- select raw_element
90
- as 'id'
91
- transform 'raw_element' => lambda { |element| element['id'] }
92
- from outlines
93
- end
94
-
95
- expect(result).to eq([{"id" => "test-feature;an-outline"}])
96
- end
97
-
98
- it 'should return steps from scenario outlines' do
99
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
100
-
101
- result = gs.query do
102
- select raw_element
103
- as steps
104
- transform 'raw_element' => lambda { |element| element['steps'] }
105
- from outlines
106
- end
107
-
108
- expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}]}])
109
- end
110
-
111
-
112
- it 'should return multiple things from scenario outlines' do
113
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
114
-
115
- result = gs.query do
116
- select name, tags
117
- from outlines
118
- end
119
-
120
- expect(result).to eq([{"name" => "An Outline", "tags" => []},
121
- {"name" => "An Outline with everything", "tags" => ["@outline_tag"]}])
122
- end
60
+ # it 'should return types from scenario outlines' do
61
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
62
+ #
63
+ # result = gs.query do
64
+ # select raw_element
65
+ # as 'type'
66
+ # transform 'raw_element' => lambda { |element| element['type'] }
67
+ # from outlines
68
+ # end
69
+ #
70
+ # expect(result).to eq([{"type" => "scenario_outline"}])
71
+ # end
72
+ #
73
+ # it 'should return step lines from scenario outlines' do
74
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
75
+ #
76
+ # result = gs.query do
77
+ # select raw_element
78
+ # as step_lines
79
+ # transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
80
+ # from outlines
81
+ # end
82
+ #
83
+ # expect(result).to eq([{"step_lines" => ["Given something happend", "Then I expect something else"]}])
84
+ # end
85
+ #
86
+ # it 'should return ids from scenario outlines' do
87
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
88
+ #
89
+ # result = gs.query do
90
+ # select raw_element
91
+ # as 'id'
92
+ # transform 'raw_element' => lambda { |element| element['id'] }
93
+ # from outlines
94
+ # end
95
+ #
96
+ # expect(result).to eq([{"id" => "test-feature;an-outline"}])
97
+ # end
98
+ #
99
+ # it 'should return steps from scenario outlines' do
100
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
101
+ #
102
+ # result = gs.query do
103
+ # select raw_element
104
+ # as steps
105
+ # transform 'raw_element' => lambda { |element| element['steps'] }
106
+ # from outlines
107
+ # end
108
+ #
109
+ # expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}]}])
110
+ # end
111
+ #
112
+ #
113
+ # it 'should return multiple things from scenario outlines' do
114
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
115
+ #
116
+ # result = gs.query do
117
+ # select name, tags
118
+ # from outlines
119
+ # end
120
+ #
121
+ # expect(result).to eq([{"name" => "An Outline", "tags" => []},
122
+ # {"name" => "An Outline with everything", "tags" => ["@outline_tag"]}])
123
+ # end
123
124
 
124
125
  it 'should return things from multiple feature files' do
125
126
  gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
@@ -156,77 +157,77 @@ describe "select" do
156
157
  end
157
158
  end
158
159
 
159
- it "should return the examples from scenario outlines" do
160
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
161
- result = gr.query do
162
- select raw_element
163
- as examples
164
- transform 'raw_element' => lambda { |element| element['examples'] }
165
- from outlines
166
- end
167
-
168
- expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "", "line" => 6,
169
- "description" => "", "id" => "test-feature;an-outline;",
170
- "rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;;1"},
171
- {"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;;2"},
172
- {"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;;3"},
173
- {"cells" => ["3", "c"], "line" => 10, "id" => "test-feature;an-outline;;4"},
174
- {"cells" => ["4", "d"], "line" => 11, "id" => "test-feature;an-outline;;5"}]}]}])
175
- end
176
-
177
- it "should return multiple examples used for a single scenario outline" do
178
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
179
- result = gr.query do
180
- select raw_element
181
- as examples
182
- transform 'raw_element' => lambda { |element| element['examples'] }
183
- from outlines
184
- end
185
-
186
- expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 6, "description" => "", "id" => "test-feature;an-outline;one",
187
- "rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;one;1"},
188
- {"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;one;2"},
189
- {"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;one;3"}]},
190
- {"keyword" => "Examples", "name" => "Two", "line" => 11, "description" => "", "id" => "test-feature;an-outline;two",
191
- "rows" => [{"cells" => ["var_a", "var_b"], "line" => 12, "id" => "test-feature;an-outline;two;1"},
192
- {"cells" => ["1", "a"], "line" => 13, "id" => "test-feature;an-outline;two;2"},
193
- {"cells" => ["2", "b"], "line" => 14, "id" => "test-feature;an-outline;two;3"}]}]},
194
- {"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 31, "description" => "This is example One.", "id" => "test-feature;an-outline-with-everything;one",
195
- "rows" => [{"cells" => ["var_a", "var_b"], "line" => 34, "id" => "test-feature;an-outline-with-everything;one;1"},
196
- {"cells" => ["1", "a"], "line" => 35, "id" => "test-feature;an-outline-with-everything;one;2"},
197
- {"cells" => ["2", "b"], "line" => 36, "id" => "test-feature;an-outline-with-everything;one;3"}]},
198
- {"keyword" => "Examples", "name" => "Two", "line" => 39, "description" => "", "tags" => [{"name" => "@example_tag", "line" => 38}], "id" => "test-feature;an-outline-with-everything;two",
199
- "rows" => [{"cells" => ["var_a", "var_b"], "line" => 40, "id" => "test-feature;an-outline-with-everything;two;1"},
200
- {"cells" => ["1", "a"], "line" => 41, "id" => "test-feature;an-outline-with-everything;two;2"},
201
- {"cells" => ["2", "b"], "line" => 42, "id" => "test-feature;an-outline-with-everything;two;3"}]}]}])
202
- end
203
-
204
- it 'should return scenario outlines name and line numbers as a map' do
205
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
206
- result = gs.query do
207
- select name, source_line, raw_element, raw_element, raw_element, raw_element
208
- as 'source_line' => 'line'
209
- as 'raw_element' => 'id'
210
- as 'raw_element' => 'type'
211
- as 'raw_element' => 'steps'
212
- as 'raw_element' => 'step_lines'
213
-
214
- transform 'raw_element' => lambda { |element| element['id'] }
215
- transform 'raw_element' => lambda { |element| element['type'] }
216
- transform 'raw_element' => lambda { |element| element['steps'] }
217
- transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
218
-
219
-
220
- from outlines
221
- end
222
-
223
- expect(result).to eq([{'name' => "An Outline",
224
- 'line' => 3,
225
- 'id' => 'test-feature;an-outline',
226
- 'type' => 'scenario_outline',
227
- "steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}],
228
- "step_lines" => ["Given something happend", "Then I expect something else"]}])
229
- end
160
+ # it "should return the examples from scenario outlines" do
161
+ # gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
162
+ # result = gr.query do
163
+ # select raw_element
164
+ # as examples
165
+ # transform 'raw_element' => lambda { |element| element['examples'] }
166
+ # from outlines
167
+ # end
168
+ #
169
+ # expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "", "line" => 6,
170
+ # "description" => "", "id" => "test-feature;an-outline;",
171
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;;1"},
172
+ # {"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;;2"},
173
+ # {"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;;3"},
174
+ # {"cells" => ["3", "c"], "line" => 10, "id" => "test-feature;an-outline;;4"},
175
+ # {"cells" => ["4", "d"], "line" => 11, "id" => "test-feature;an-outline;;5"}]}]}])
176
+ # end
177
+
178
+ # it "should return multiple examples used for a single scenario outline" do
179
+ # gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
180
+ # result = gr.query do
181
+ # select raw_element
182
+ # as examples
183
+ # transform 'raw_element' => lambda { |element| element['examples'] }
184
+ # from outlines
185
+ # end
186
+ #
187
+ # expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 6, "description" => "", "id" => "test-feature;an-outline;one",
188
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;one;1"},
189
+ # {"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;one;2"},
190
+ # {"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;one;3"}]},
191
+ # {"keyword" => "Examples", "name" => "Two", "line" => 11, "description" => "", "id" => "test-feature;an-outline;two",
192
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 12, "id" => "test-feature;an-outline;two;1"},
193
+ # {"cells" => ["1", "a"], "line" => 13, "id" => "test-feature;an-outline;two;2"},
194
+ # {"cells" => ["2", "b"], "line" => 14, "id" => "test-feature;an-outline;two;3"}]}]},
195
+ # {"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 31, "description" => "This is example One.", "id" => "test-feature;an-outline-with-everything;one",
196
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 34, "id" => "test-feature;an-outline-with-everything;one;1"},
197
+ # {"cells" => ["1", "a"], "line" => 35, "id" => "test-feature;an-outline-with-everything;one;2"},
198
+ # {"cells" => ["2", "b"], "line" => 36, "id" => "test-feature;an-outline-with-everything;one;3"}]},
199
+ # {"keyword" => "Examples", "name" => "Two", "line" => 39, "description" => "", "tags" => [{"name" => "@example_tag", "line" => 38}], "id" => "test-feature;an-outline-with-everything;two",
200
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 40, "id" => "test-feature;an-outline-with-everything;two;1"},
201
+ # {"cells" => ["1", "a"], "line" => 41, "id" => "test-feature;an-outline-with-everything;two;2"},
202
+ # {"cells" => ["2", "b"], "line" => 42, "id" => "test-feature;an-outline-with-everything;two;3"}]}]}])
203
+ # end
204
+ #
205
+ # it 'should return scenario outlines name and line numbers as a map' do
206
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
207
+ # result = gs.query do
208
+ # select name, source_line, raw_element, raw_element, raw_element, raw_element
209
+ # as 'source_line' => 'line'
210
+ # as 'raw_element' => 'id'
211
+ # as 'raw_element' => 'type'
212
+ # as 'raw_element' => 'steps'
213
+ # as 'raw_element' => 'step_lines'
214
+ #
215
+ # transform 'raw_element' => lambda { |element| element['id'] }
216
+ # transform 'raw_element' => lambda { |element| element['type'] }
217
+ # transform 'raw_element' => lambda { |element| element['steps'] }
218
+ # transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
219
+ #
220
+ #
221
+ # from outlines
222
+ # end
223
+ #
224
+ # expect(result).to eq([{'name' => "An Outline",
225
+ # 'line' => 3,
226
+ # 'id' => 'test-feature;an-outline',
227
+ # 'type' => 'scenario_outline',
228
+ # "steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}],
229
+ # "step_lines" => ["Given something happend", "Then I expect something else"]}])
230
+ # end
230
231
 
231
232
  end
232
233
  end
@@ -3,37 +3,6 @@ require 'spec_helper'
3
3
  describe "select" do
4
4
  describe 'from scenarios' do
5
5
 
6
- it 'should return tags from scenarios' do
7
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tags2")
8
-
9
- result = gs.query do
10
- select tags
11
- from scenarios
12
- end
13
-
14
- expect(result).to match_array([{"tags" => ["@two"]},
15
- {"tags" => ["@one"]},
16
- {"tags" => []},
17
- {"tags" => ["@two"]},
18
- {"tags" => ["@one"]},
19
- {"tags" => ["@two", "@four"]},
20
- {"tags" => ["@one", "@five"]},
21
- {"tags" => []},
22
- {"tags" => ["@two"]},
23
- {"tags" => ["@one"]}])
24
- end
25
-
26
- it 'should return descriptions from scenarios' do
27
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/table")
28
-
29
- result = gs.query do
30
- select description_text
31
- from scenarios
32
- end
33
-
34
- expect(result).to eq([{"description_text" => "Scenario description."}])
35
- end
36
-
37
6
  it 'should return lines from scenarios' do
38
7
  gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
39
8
 
@@ -57,80 +26,80 @@ describe "select" do
57
26
  {"name" => "Testing yet again"}, {"name" => "Testing yet again part 2"}])
58
27
  end
59
28
 
60
- it 'should return types from scenarios' do
61
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
62
-
63
- result = gs.query do
64
- select raw_element
65
- as 'type'
66
- transform 'raw_element' => lambda { |element| element['type'] }
67
- from scenarios
68
- end
69
-
70
- expect(result).to eq([{"type" => "scenario"}, {"type" => "scenario"},
71
- {"type" => "scenario"}, {"type" => "scenario"}])
72
- end
73
-
74
- it 'should return step lines from scenarios' do
75
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
76
-
77
- result = gs.query do
78
- select raw_element
79
- as step_lines
80
- transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
81
- from scenarios
82
- end
83
-
84
- expect(result).to eq([{"step_lines" => ["Given something happend", "Then I expect something else"]},
85
- {"step_lines" => ["Given something happend", "Then I expect something else"]},
86
- {"step_lines" => ["Given something happend", "Then I expect something else"]},
87
- {"step_lines" => ["Given something happend", "Then I expect something else"]}])
88
- end
89
-
90
- it 'should return ids from scenarios' do
91
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
92
-
93
- result = gs.query do
94
- select raw_element
95
- as 'id'
96
- transform 'raw_element' => lambda { |element| element['id'] }
97
- from scenarios
98
- end
99
-
100
- expect(result).to eq([{"id" => "test3-feature;testing-the-slurping"},
101
- {"id" => "test3-feature;testing-again"},
102
- {"id" => "test3-feature;testing-yet-again"},
103
- {"id" => "test3-feature;testing-yet-again-part-2"},])
104
- end
105
-
106
- it 'should return steps from scenarios' do
107
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
108
-
109
- result = gs.query do
110
- select raw_element
111
- as steps
112
- transform 'raw_element' => lambda { |element| element['steps'] }
113
- from scenarios
114
- end
115
-
116
- expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 7}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 8}]},
117
- {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 12}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 13}]},
118
- {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 17}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 18}]},
119
- {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 22}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 23}]}])
120
- end
29
+ # it 'should return types from scenarios' do
30
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
31
+ #
32
+ # result = gs.query do
33
+ # select raw_element
34
+ # as 'type'
35
+ # transform 'raw_element' => lambda { |element| element['type'] }
36
+ # from scenarios
37
+ # end
38
+ #
39
+ # expect(result).to eq([{"type" => "scenario"}, {"type" => "scenario"},
40
+ # {"type" => "scenario"}, {"type" => "scenario"}])
41
+ # end
42
+ #
43
+ # it 'should return step lines from scenarios' do
44
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
45
+ #
46
+ # result = gs.query do
47
+ # select raw_element
48
+ # as step_lines
49
+ # transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
50
+ # from scenarios
51
+ # end
52
+ #
53
+ # expect(result).to eq([{"step_lines" => ["Given something happend", "Then I expect something else"]},
54
+ # {"step_lines" => ["Given something happend", "Then I expect something else"]},
55
+ # {"step_lines" => ["Given something happend", "Then I expect something else"]},
56
+ # {"step_lines" => ["Given something happend", "Then I expect something else"]}])
57
+ # end
58
+ #
59
+ # it 'should return ids from scenarios' do
60
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
61
+ #
62
+ # result = gs.query do
63
+ # select raw_element
64
+ # as 'id'
65
+ # transform 'raw_element' => lambda { |element| element['id'] }
66
+ # from scenarios
67
+ # end
68
+ #
69
+ # expect(result).to eq([{"id" => "test3-feature;testing-the-slurping"},
70
+ # {"id" => "test3-feature;testing-again"},
71
+ # {"id" => "test3-feature;testing-yet-again"},
72
+ # {"id" => "test3-feature;testing-yet-again-part-2"},])
73
+ # end
74
+ #
75
+ # it 'should return steps from scenarios' do
76
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
77
+ #
78
+ # result = gs.query do
79
+ # select raw_element
80
+ # as steps
81
+ # transform 'raw_element' => lambda { |element| element['steps'] }
82
+ # from scenarios
83
+ # end
84
+ #
85
+ # expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 7}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 8}]},
86
+ # {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 12}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 13}]},
87
+ # {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 17}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 18}]},
88
+ # {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 22}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 23}]}])
89
+ # end
121
90
 
122
91
  it 'should return multiple things from scenarios' do
123
92
  gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
124
93
 
125
94
  result = gs.query do
126
- select name, tags
95
+ select name, source_line
127
96
  from scenarios
128
97
  end
129
98
 
130
- expect(result).to eq([{"name" => "Testing the slurping", "tags" => ["@one"]},
131
- {"name" => "Testing again", "tags" => ["@two"]},
132
- {"name" => "Testing yet again", "tags" => ["@one"]},
133
- {"name" => "Testing yet again part 2", "tags" => ["@one", "@two"]}])
99
+ expect(result).to eq([{"name" => "Testing the slurping", "source_line" => 6},
100
+ {"name" => "Testing again", "source_line" => 11},
101
+ {"name" => "Testing yet again", "source_line" => 16},
102
+ {"name" => "Testing yet again part 2", "source_line" => 21}])
134
103
  end
135
104
 
136
105
  it 'should return things from multiple feature files' do
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,7 @@ end
5
5
 
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/../lib/cql"
8
+ require "#{File.dirname(__FILE__)}/../testing/cql_test_model"
8
9
  require "#{File.dirname(__FILE__)}/tag_filterable_specs"
9
10
  require "#{File.dirname(__FILE__)}/name_filterable_specs"
10
11
  require "#{File.dirname(__FILE__)}/line_count_filterable_specs"
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Eric Kessler
@@ -10,118 +9,118 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2015-11-28 00:00:00.000000000 Z
12
+ date: 2016-09-26 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: cuke_modeler
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - "<"
21
19
  - !ruby/object:Gem::Version
22
- version: '0'
20
+ version: '2.0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - "<"
29
26
  - !ruby/object:Gem::Version
30
- version: '0'
27
+ version: '2.0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0.9'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0.9'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ~>
46
+ - - "~>"
53
47
  - !ruby/object:Gem::Version
54
48
  version: '2.7'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ~>
53
+ - - "~>"
61
54
  - !ruby/object:Gem::Version
62
55
  version: '2.7'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: cucumber
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - ">="
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - ">="
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: simplecov
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - ">="
85
75
  - !ruby/object:Gem::Version
86
76
  version: '0'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - ">="
93
82
  - !ruby/object:Gem::Version
94
83
  version: '0'
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: racatt
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
- - - ! '>='
88
+ - - ">="
101
89
  - !ruby/object:Gem::Version
102
90
  version: '0'
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
- - - ! '>='
95
+ - - ">="
109
96
  - !ruby/object:Gem::Version
110
97
  version: '0'
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: coveralls
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
- - - ! '>='
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: relish
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
122
  requirements:
124
- - - ! '>='
123
+ - - ">="
125
124
  - !ruby/object:Gem::Version
126
125
  version: '0'
127
126
  description: Cucumber Query Language
@@ -130,13 +129,13 @@ executables: []
130
129
  extensions: []
131
130
  extra_rdoc_files: []
132
131
  files:
132
+ - lib/cql.rb
133
133
  - lib/cql/dsl.rb
134
134
  - lib/cql/feature_filters.rb
135
135
  - lib/cql/filters.rb
136
136
  - lib/cql/map_reduce.rb
137
137
  - lib/cql/sso_filters.rb
138
138
  - lib/cql/version.rb
139
- - lib/cql.rb
140
139
  - spec/dsl_spec.rb
141
140
  - spec/filter_example_spec.rb
142
141
  - spec/filter_feature_dsl_spec.rb
@@ -148,46 +147,41 @@ files:
148
147
  - spec/name_filterable_specs.rb
149
148
  - spec/repository_spec.rb
150
149
  - spec/select_feature_dsl_spec.rb
151
- - spec/select_scenario_dsl_spec.rb
152
150
  - spec/select_scen_outline_dsl_spec.rb
151
+ - spec/select_scenario_dsl_spec.rb
153
152
  - spec/spec_helper.rb
154
153
  - spec/tag_filterable_specs.rb
155
154
  homepage: https://github.com/enkessler/cql
156
155
  licenses:
157
156
  - MIT
158
- post_install_message: ! '
157
+ metadata: {}
158
+ post_install_message: |2+
159
159
 
160
160
  (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
161
161
 
162
-
163
162
  Thank you for installing cql (Cucumber Query Language)
164
163
 
165
-
166
164
  (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
167
165
 
168
-
169
- '
170
166
  rdoc_options:
171
- - --charset=UTF-8
167
+ - "--charset=UTF-8"
172
168
  require_paths:
173
169
  - lib
174
170
  required_ruby_version: !ruby/object:Gem::Requirement
175
- none: false
176
171
  requirements:
177
- - - ! '>='
172
+ - - ">="
178
173
  - !ruby/object:Gem::Version
179
174
  version: '0'
180
175
  required_rubygems_version: !ruby/object:Gem::Requirement
181
- none: false
182
176
  requirements:
183
- - - ! '>='
177
+ - - ">="
184
178
  - !ruby/object:Gem::Version
185
179
  version: '0'
186
180
  requirements: []
187
181
  rubyforge_project:
188
- rubygems_version: 1.8.29
182
+ rubygems_version: 2.2.5
189
183
  signing_key:
190
- specification_version: 3
184
+ specification_version: 4
191
185
  summary: A gem providing functionality to query a Cucumber test suite.
192
186
  test_files:
193
187
  - spec/dsl_spec.rb
@@ -205,4 +199,3 @@ test_files:
205
199
  - spec/select_scen_outline_dsl_spec.rb
206
200
  - spec/spec_helper.rb
207
201
  - spec/tag_filterable_specs.rb
208
- has_rdoc: