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,114 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+
4
+ describe "select" do
5
+ describe "from features" do
6
+
7
+ it 'should return names from features' do
8
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
9
+
10
+ result = gs.query do
11
+ select name
12
+ from features
13
+ end
14
+
15
+ expect(result).to match_array([{"name" => "Simple"}, {"name" => "Test Feature"},
16
+ {"name" => "Test2 Feature"}, {"name" => "Test3 Feature"}])
17
+ end
18
+
19
+ # it 'should return descriptions from features' do
20
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
21
+ #
22
+ # result = gs.query do
23
+ # select description_text
24
+ # from features
25
+ # end
26
+ #
27
+ # expect(result).to eq([{"description_text" => "The cat in the hat"}])
28
+ # end
29
+
30
+ it 'should return paths from from feature files' do
31
+ repo_path = "#{@feature_fixtures_directory}/scenario/simple"
32
+ gs = CQL::Repository.new(repo_path)
33
+
34
+ result = gs.query do
35
+ select path
36
+ from feature_files
37
+ end
38
+
39
+ expect(result).to match_array([{'path' => "#{repo_path}/simple.feature"},
40
+ {'path' => "#{repo_path}/test.feature"},
41
+ {'path' => "#{repo_path}/test2.feature"},
42
+ {'path' => "#{repo_path}/test_full.feature"}])
43
+ end
44
+
45
+ # it 'should return tags from features' do
46
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
47
+ #
48
+ # result = gs.query do
49
+ # select tags
50
+ # from features
51
+ # end
52
+ #
53
+ # expect(result).to match_array([{"tags" => []},
54
+ # {"tags" => ["@one"]},
55
+ # {"tags" => ["@two"]},
56
+ # {"tags" => ["@one", "@two"]}])
57
+ # end
58
+ #
59
+ #
60
+ # it 'should return multiple things from features' do
61
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
62
+ #
63
+ # result = gs.query do
64
+ # select name, tags
65
+ # from features
66
+ # end
67
+ #
68
+ # expect(result).to match_array([{"name" => "Simple", "tags" => []},
69
+ # {"name" => "Test Feature", "tags" => ["@one"]},
70
+ # {"name" => "Test2 Feature", "tags" => ["@two"]},
71
+ # {"name" => "Test3 Feature", "tags" => ["@one", "@two"]}])
72
+ # end
73
+
74
+ it 'should return things from multiple feature files' do
75
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/combined/b")
76
+
77
+ result = gr.query do
78
+ select name
79
+ from features
80
+ end
81
+
82
+ expect(result).to match_array([{"name" => "f1_1_tag"},
83
+ {"name" => "f2_2_tags"},
84
+ {"name" => "f3_3_tags"}])
85
+ end
86
+
87
+ it 'should return multiple features as a list of maps' do
88
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/combined/b")
89
+
90
+ result = gr.query do
91
+ select name
92
+ from features
93
+ end
94
+
95
+ expect(result).to match_array([{"name" => "f1_1_tag"},
96
+ {"name" => "f2_2_tags"},
97
+ {"name" => "f3_3_tags"}])
98
+ end
99
+
100
+ # it 'should return ids from features' do
101
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
102
+ #
103
+ # result = gs.query do
104
+ # select raw_element
105
+ # as 'id'
106
+ # transform 'raw_element' => lambda { |element| element['id'] }
107
+ # from features
108
+ # end
109
+ #
110
+ # expect(result).to eq([{"id" => "test3-feature"}])
111
+ # end
112
+
113
+ end
114
+ end
@@ -0,0 +1,234 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+
4
+ describe "select" do
5
+ describe 'from scenario_outlines' do
6
+
7
+ # it 'should return tags from scenario outlines' do
8
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
9
+ #
10
+ # result = gs.query do
11
+ # select tags
12
+ # from outlines
13
+ # end
14
+ #
15
+ # expect(result).to match_array([{"tags" => ["@two"]},
16
+ # {"tags" => ["@one"]},
17
+ # {"tags" => []},
18
+ # {"tags" => ["@two"]},
19
+ # {"tags" => ["@one"]},
20
+ # {"tags" => ["@two", "@four"]},
21
+ # {"tags" => ["@one", "@five"]},
22
+ # {"tags" => []},
23
+ # {"tags" => ["@two"]},
24
+ # {"tags" => ["@one"]}])
25
+ # end
26
+ #
27
+ # it 'should return descriptions from scenario outlines' do
28
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
29
+ #
30
+ # result = gs.query do
31
+ # select description_text
32
+ # from outlines
33
+ # end
34
+ #
35
+ # expect(result).to eq([{"description_text" => ""}, {"description_text" => "\nOutline description."}])
36
+ # end
37
+ #
38
+
39
+ it 'should return lines from scenario outlines' do
40
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
41
+
42
+ result = gs.query do
43
+ select source_line
44
+ from outlines
45
+ end
46
+
47
+ expect(result).to eq([{"source_line" => 3}])
48
+ end
49
+
50
+ it 'should return names from scenario outlines' do
51
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
52
+
53
+ result = gs.query do
54
+ select name
55
+ from outlines
56
+ end
57
+
58
+ expect(result).to eq([{"name" => "An Outline"}])
59
+ end
60
+
61
+ # it 'should return types from scenario outlines' do
62
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
63
+ #
64
+ # result = gs.query do
65
+ # select raw_element
66
+ # as 'type'
67
+ # transform 'raw_element' => lambda { |element| element['type'] }
68
+ # from outlines
69
+ # end
70
+ #
71
+ # expect(result).to eq([{"type" => "scenario_outline"}])
72
+ # end
73
+ #
74
+ # it 'should return step lines from scenario outlines' do
75
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
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 outlines
82
+ # end
83
+ #
84
+ # expect(result).to eq([{"step_lines" => ["Given something happend", "Then I expect something else"]}])
85
+ # end
86
+ #
87
+ # it 'should return ids from scenario outlines' do
88
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
89
+ #
90
+ # result = gs.query do
91
+ # select raw_element
92
+ # as 'id'
93
+ # transform 'raw_element' => lambda { |element| element['id'] }
94
+ # from outlines
95
+ # end
96
+ #
97
+ # expect(result).to eq([{"id" => "test-feature;an-outline"}])
98
+ # end
99
+ #
100
+ # it 'should return steps from scenario outlines' do
101
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
102
+ #
103
+ # result = gs.query do
104
+ # select raw_element
105
+ # as steps
106
+ # transform 'raw_element' => lambda { |element| element['steps'] }
107
+ # from outlines
108
+ # end
109
+ #
110
+ # expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}]}])
111
+ # end
112
+ #
113
+ #
114
+ # it 'should return multiple things from scenario outlines' do
115
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
116
+ #
117
+ # result = gs.query do
118
+ # select name, tags
119
+ # from outlines
120
+ # end
121
+ #
122
+ # expect(result).to eq([{"name" => "An Outline", "tags" => []},
123
+ # {"name" => "An Outline with everything", "tags" => ["@outline_tag"]}])
124
+ # end
125
+
126
+ it 'should return things from multiple feature files' do
127
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
128
+
129
+ result = gr.query do
130
+ select name
131
+ from outlines
132
+ end
133
+
134
+ expect(result).to match_array([{"name" => "Has a table"},
135
+ {"name" => "Next"},
136
+ {"name" => "Another"},
137
+ {"name" => "Blah"},
138
+ {"name" => "Another"},
139
+ {"name" => "Has a table hmmm"},
140
+ {"name" => "Next"},
141
+ {"name" => "Another"},
142
+ {"name" => "Blah blah"},
143
+ {"name" => "Another"}])
144
+ end
145
+
146
+ it 'should return multiple scenario outlines as a list of maps' do
147
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines")
148
+
149
+ result = gr.query do
150
+ select name
151
+ from outlines
152
+ end
153
+
154
+ expect(result).to be_an_instance_of(Array)
155
+
156
+ result.each do |item|
157
+ expect(item).to be_an_instance_of(Hash)
158
+ end
159
+ end
160
+
161
+ # it "should return the examples from scenario outlines" do
162
+ # gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
163
+ # result = gr.query do
164
+ # select raw_element
165
+ # as examples
166
+ # transform 'raw_element' => lambda { |element| element['examples'] }
167
+ # from outlines
168
+ # end
169
+ #
170
+ # expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "", "line" => 6,
171
+ # "description" => "", "id" => "test-feature;an-outline;",
172
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;;1"},
173
+ # {"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;;2"},
174
+ # {"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;;3"},
175
+ # {"cells" => ["3", "c"], "line" => 10, "id" => "test-feature;an-outline;;4"},
176
+ # {"cells" => ["4", "d"], "line" => 11, "id" => "test-feature;an-outline;;5"}]}]}])
177
+ # end
178
+
179
+ # it "should return multiple examples used for a single scenario outline" do
180
+ # gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/multiple_examples")
181
+ # result = gr.query do
182
+ # select raw_element
183
+ # as examples
184
+ # transform 'raw_element' => lambda { |element| element['examples'] }
185
+ # from outlines
186
+ # end
187
+ #
188
+ # expect(result).to eq([{"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 6, "description" => "", "id" => "test-feature;an-outline;one",
189
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 7, "id" => "test-feature;an-outline;one;1"},
190
+ # {"cells" => ["1", "a"], "line" => 8, "id" => "test-feature;an-outline;one;2"},
191
+ # {"cells" => ["2", "b"], "line" => 9, "id" => "test-feature;an-outline;one;3"}]},
192
+ # {"keyword" => "Examples", "name" => "Two", "line" => 11, "description" => "", "id" => "test-feature;an-outline;two",
193
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 12, "id" => "test-feature;an-outline;two;1"},
194
+ # {"cells" => ["1", "a"], "line" => 13, "id" => "test-feature;an-outline;two;2"},
195
+ # {"cells" => ["2", "b"], "line" => 14, "id" => "test-feature;an-outline;two;3"}]}]},
196
+ # {"examples" => [{"keyword" => "Examples", "name" => "One", "line" => 31, "description" => "This is example One.", "id" => "test-feature;an-outline-with-everything;one",
197
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 34, "id" => "test-feature;an-outline-with-everything;one;1"},
198
+ # {"cells" => ["1", "a"], "line" => 35, "id" => "test-feature;an-outline-with-everything;one;2"},
199
+ # {"cells" => ["2", "b"], "line" => 36, "id" => "test-feature;an-outline-with-everything;one;3"}]},
200
+ # {"keyword" => "Examples", "name" => "Two", "line" => 39, "description" => "", "tags" => [{"name" => "@example_tag", "line" => 38}], "id" => "test-feature;an-outline-with-everything;two",
201
+ # "rows" => [{"cells" => ["var_a", "var_b"], "line" => 40, "id" => "test-feature;an-outline-with-everything;two;1"},
202
+ # {"cells" => ["1", "a"], "line" => 41, "id" => "test-feature;an-outline-with-everything;two;2"},
203
+ # {"cells" => ["2", "b"], "line" => 42, "id" => "test-feature;an-outline-with-everything;two;3"}]}]}])
204
+ # end
205
+ #
206
+ # it 'should return scenario outlines name and line numbers as a map' do
207
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
208
+ # result = gs.query do
209
+ # select name, source_line, raw_element, raw_element, raw_element, raw_element
210
+ # as 'source_line' => 'line'
211
+ # as 'raw_element' => 'id'
212
+ # as 'raw_element' => 'type'
213
+ # as 'raw_element' => 'steps'
214
+ # as 'raw_element' => 'step_lines'
215
+ #
216
+ # transform 'raw_element' => lambda { |element| element['id'] }
217
+ # transform 'raw_element' => lambda { |element| element['type'] }
218
+ # transform 'raw_element' => lambda { |element| element['steps'] }
219
+ # transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
220
+ #
221
+ #
222
+ # from outlines
223
+ # end
224
+ #
225
+ # expect(result).to eq([{'name' => "An Outline",
226
+ # 'line' => 3,
227
+ # 'id' => 'test-feature;an-outline',
228
+ # 'type' => 'scenario_outline',
229
+ # "steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 4}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 5}],
230
+ # "step_lines" => ["Given something happend", "Then I expect something else"]}])
231
+ # end
232
+
233
+ end
234
+ end
@@ -0,0 +1,132 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+
4
+ describe "select" do
5
+ describe 'from scenarios' do
6
+
7
+ it 'should return lines from scenarios' do
8
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
9
+
10
+ result = gr.query do
11
+ select source_line
12
+ from scenarios
13
+ end
14
+
15
+ expect(result).to eq([{"source_line" => 6}, {"source_line" => 11}, {"source_line" => 16}, {"source_line" => 21}])
16
+ end
17
+
18
+ it 'should return names from scenarios' do
19
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
20
+
21
+ result = gr.query do
22
+ select name
23
+ from scenarios
24
+ end
25
+
26
+ expect(result).to eq([{"name" => "Testing the slurping"}, {"name" => "Testing again"},
27
+ {"name" => "Testing yet again"}, {"name" => "Testing yet again part 2"}])
28
+ end
29
+
30
+ # it 'should return types from scenarios' do
31
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
32
+ #
33
+ # result = gs.query do
34
+ # select raw_element
35
+ # as 'type'
36
+ # transform 'raw_element' => lambda { |element| element['type'] }
37
+ # from scenarios
38
+ # end
39
+ #
40
+ # expect(result).to eq([{"type" => "scenario"}, {"type" => "scenario"},
41
+ # {"type" => "scenario"}, {"type" => "scenario"}])
42
+ # end
43
+ #
44
+ # it 'should return step lines from scenarios' do
45
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
46
+ #
47
+ # result = gs.query do
48
+ # select raw_element
49
+ # as step_lines
50
+ # transform 'raw_element' => lambda { |element| element['steps'].collect { |step| step['keyword'] + step['name'] } }
51
+ # from scenarios
52
+ # end
53
+ #
54
+ # expect(result).to eq([{"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
+ # {"step_lines" => ["Given something happend", "Then I expect something else"]}])
58
+ # end
59
+ #
60
+ # it 'should return ids 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 'id'
66
+ # transform 'raw_element' => lambda { |element| element['id'] }
67
+ # from scenarios
68
+ # end
69
+ #
70
+ # expect(result).to eq([{"id" => "test3-feature;testing-the-slurping"},
71
+ # {"id" => "test3-feature;testing-again"},
72
+ # {"id" => "test3-feature;testing-yet-again"},
73
+ # {"id" => "test3-feature;testing-yet-again-part-2"},])
74
+ # end
75
+ #
76
+ # it 'should return steps from scenarios' do
77
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
78
+ #
79
+ # result = gs.query do
80
+ # select raw_element
81
+ # as steps
82
+ # transform 'raw_element' => lambda { |element| element['steps'] }
83
+ # from scenarios
84
+ # end
85
+ #
86
+ # expect(result).to eq([{"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 7}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 8}]},
87
+ # {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 12}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 13}]},
88
+ # {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 17}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 18}]},
89
+ # {"steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 22}, {"keyword" => "Then ", "name" => "I expect something else", "line" => 23}]}])
90
+ # end
91
+
92
+ it 'should return multiple things from scenarios' do
93
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
94
+
95
+ result = gs.query do
96
+ select name, source_line
97
+ from scenarios
98
+ end
99
+
100
+ expect(result).to eq([{"name" => "Testing the slurping", "source_line" => 6},
101
+ {"name" => "Testing again", "source_line" => 11},
102
+ {"name" => "Testing yet again", "source_line" => 16},
103
+ {"name" => "Testing yet again part 2", "source_line" => 21}])
104
+ end
105
+
106
+ it 'should return things from multiple feature files' do
107
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
108
+
109
+ result = gr.query do
110
+ select name
111
+ from scenarios
112
+ end
113
+
114
+ expect(result).to match_array([{"name" => "Has a table"}, {"name" => "Testing the slurping 1"},
115
+ {"name" => "Testing the slurping not to be found"}, {"name" => "Testing the slurping 2"},
116
+ {"name" => "Testing the slurping 3"}, {"name" => "Testing again"},
117
+ {"name" => "Testing yet again"}, {"name" => "Testing yet again part 2"}])
118
+ end
119
+
120
+ it 'should get multiple scenarios as a list of maps' do
121
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
122
+ result = gr.query do
123
+ select source_line, name
124
+ from scenarios
125
+ end
126
+
127
+ expect(result).to eq([{'source_line' => 6, 'name' => "Testing the slurping"}, {'source_line' => 11, 'name' => "Testing again"},
128
+ {'source_line' => 16, 'name' => "Testing yet again"}, {'source_line' => 21, 'name' => "Testing yet again part 2"}])
129
+ end
130
+
131
+ end
132
+ end