cql 1.2.0 → 1.2.1

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.
@@ -1,233 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "select" do
4
- describe 'from scenario_outlines' do
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
36
- #
37
-
38
- it 'should return lines from scenario outlines' do
39
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
40
-
41
- result = gs.query do
42
- select source_line
43
- from outlines
44
- end
45
-
46
- expect(result).to eq([{"source_line" => 3}])
47
- end
48
-
49
- it 'should return names from scenario outlines' do
50
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/basic")
51
-
52
- result = gs.query do
53
- select name
54
- from outlines
55
- end
56
-
57
- expect(result).to eq([{"name" => "An Outline"}])
58
- end
59
-
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
124
-
125
- it 'should return things from multiple feature files' do
126
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines/filters/tags2")
127
-
128
- result = gr.query do
129
- select name
130
- from outlines
131
- end
132
-
133
- expect(result).to match_array([{"name" => "Has a table"},
134
- {"name" => "Next"},
135
- {"name" => "Another"},
136
- {"name" => "Blah"},
137
- {"name" => "Another"},
138
- {"name" => "Has a table hmmm"},
139
- {"name" => "Next"},
140
- {"name" => "Another"},
141
- {"name" => "Blah blah"},
142
- {"name" => "Another"}])
143
- end
144
-
145
- it 'should return multiple scenario outlines as a list of maps' do
146
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scen_outlines")
147
-
148
- result = gr.query do
149
- select name
150
- from outlines
151
- end
152
-
153
- expect(result).to be_an_instance_of(Array)
154
-
155
- result.each do |item|
156
- expect(item).to be_an_instance_of(Hash)
157
- end
158
- end
159
-
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
231
-
232
- end
233
- end
@@ -1,131 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "select" do
4
- describe 'from scenarios' do
5
-
6
- it 'should return lines from scenarios' do
7
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
8
-
9
- result = gr.query do
10
- select source_line
11
- from scenarios
12
- end
13
-
14
- expect(result).to eq([{"source_line" => 6}, {"source_line" => 11}, {"source_line" => 16}, {"source_line" => 21}])
15
- end
16
-
17
- it 'should return names from scenarios' do
18
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
19
-
20
- result = gr.query do
21
- select name
22
- from scenarios
23
- end
24
-
25
- expect(result).to eq([{"name" => "Testing the slurping"}, {"name" => "Testing again"},
26
- {"name" => "Testing yet again"}, {"name" => "Testing yet again part 2"}])
27
- end
28
-
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
90
-
91
- it 'should return multiple things from scenarios' do
92
- gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
93
-
94
- result = gs.query do
95
- select name, source_line
96
- from scenarios
97
- end
98
-
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}])
103
- end
104
-
105
- it 'should return things from multiple feature files' do
106
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
107
-
108
- result = gr.query do
109
- select name
110
- from scenarios
111
- end
112
-
113
- expect(result).to match_array([{"name" => "Has a table"}, {"name" => "Testing the slurping 1"},
114
- {"name" => "Testing the slurping not to be found"}, {"name" => "Testing the slurping 2"},
115
- {"name" => "Testing the slurping 3"}, {"name" => "Testing again"},
116
- {"name" => "Testing yet again"}, {"name" => "Testing yet again part 2"}])
117
- end
118
-
119
- it 'should get multiple scenarios as a list of maps' do
120
- gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
121
- result = gr.query do
122
- select source_line, name
123
- from scenarios
124
- end
125
-
126
- expect(result).to eq([{'source_line' => 6, 'name' => "Testing the slurping"}, {'source_line' => 11, 'name' => "Testing again"},
127
- {'source_line' => 16, 'name' => "Testing yet again"}, {'source_line' => 21, 'name' => "Testing yet again part 2"}])
128
- end
129
-
130
- end
131
- end
data/spec/spec_helper.rb DELETED
@@ -1,31 +0,0 @@
1
- unless RUBY_VERSION.to_s < '1.9.0'
2
- require 'simplecov'
3
- SimpleCov.command_name('cql-rspec')
4
- end
5
-
6
-
7
- require "#{File.dirname(__FILE__)}/../lib/cql"
8
- require "#{File.dirname(__FILE__)}/../testing/cql_test_model"
9
- require "#{File.dirname(__FILE__)}/tag_filterable_specs"
10
- require "#{File.dirname(__FILE__)}/name_filterable_specs"
11
- require "#{File.dirname(__FILE__)}/line_count_filterable_specs"
12
- require "#{File.dirname(__FILE__)}/line_filterable_specs"
13
-
14
- CQL_FEATURE_FIXTURES_DIRECTORY = "#{File.dirname(__FILE__)}/../fixtures/features"
15
-
16
-
17
- RSpec.configure do |config|
18
- config.before(:all) do
19
- @feature_fixtures_directory = CQL_FEATURE_FIXTURES_DIRECTORY
20
- end
21
-
22
- config.before(:each) do
23
- # Nothing yet
24
- end
25
-
26
- config.after(:each) do
27
- # Nothing yet
28
- end
29
- end
30
-
31
-
@@ -1,106 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for 'a tag filterable target set' do |target_type, test_data|
4
-
5
- describe 'tag filters' do
6
-
7
- it 'should filter by a single tag' do
8
- gs = CQL::Repository.new(test_data[:single_tag][:fixture_location])
9
-
10
- expected_results = test_data[:single_tag][:expected_results]
11
-
12
- expected_results.each do |tag, expected|
13
- result = gs.query do
14
- select name
15
- from target_type
16
- with tags tag
17
- end
18
-
19
- expect(result).to match_array(expected)
20
- end
21
- end
22
-
23
- it 'should filter by a multiple tags' do
24
- gs = CQL::Repository.new(test_data[:multiple_tags][:fixture_location])
25
-
26
- expected_results = test_data[:multiple_tags][:expected_results]
27
-
28
- expected_results.each do |filter_tags, expected|
29
- result = gs.query do
30
- select name
31
- from target_type
32
- with tags *filter_tags
33
- end
34
-
35
- expect(result).to eq(expected)
36
- end
37
- end
38
-
39
- it "should filter based on 'tc lt'" do
40
- gs = CQL::Repository.new(test_data[:tc_lt][:fixture_location])
41
-
42
- expected_results = test_data[:tc_lt][:expected_results]
43
-
44
- expected_results.each do |number, expected|
45
- result = gs.query do
46
- select name
47
- from target_type
48
- with tc lt number
49
- end
50
-
51
- expect(result).to match_array(expected)
52
- end
53
- end
54
-
55
- it "should filter features by 'tc lte'" do
56
- gs = CQL::Repository.new(test_data[:tc_lte][:fixture_location])
57
-
58
- expected_results = test_data[:tc_lte][:expected_results]
59
-
60
- expected_results.each do |number, expected|
61
- result = gs.query do
62
- select name
63
- from target_type
64
- with tc lte number
65
- end
66
-
67
- expect(result).to match_array(expected)
68
- end
69
- end
70
-
71
-
72
- it "should filter features by 'tc gt'" do
73
- gs = CQL::Repository.new(test_data[:tc_gt][:fixture_location])
74
-
75
- expected_results = test_data[:tc_gt][:expected_results]
76
-
77
- expected_results.each do |number, expected|
78
- result = gs.query do
79
- select name
80
- from target_type
81
- with tc gt number
82
- end
83
-
84
- expect(result).to match_array(expected)
85
- end
86
- end
87
-
88
-
89
- it "should filter features by 'tc gte'" do
90
- gs = CQL::Repository.new(test_data[:tc_gte][:fixture_location])
91
-
92
- expected_results = test_data[:tc_gte][:expected_results]
93
-
94
- expected_results.each do |number, expected|
95
- result = gs.query do
96
- select name
97
- from target_type
98
- with tc gte number
99
- end
100
-
101
- expect(result).to match_array(expected)
102
- end
103
- end
104
- end
105
-
106
- end