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.
- checksums.yaml +4 -4
- data/lib/cql/version.rb +1 -1
- metadata +43 -59
- data/spec/dsl_spec.rb +0 -289
- data/spec/filter_example_spec.rb +0 -65
- data/spec/filter_feature_dsl_spec.rb +0 -285
- data/spec/filter_sso_spec.rb +0 -201
- data/spec/line_count_filterable_specs.rb +0 -73
- data/spec/line_filterable_specs.rb +0 -51
- data/spec/map_reduce_spec.rb +0 -134
- data/spec/multiple_queries_spec.rb +0 -23
- data/spec/name_filterable_specs.rb +0 -51
- data/spec/repository_spec.rb +0 -21
- data/spec/select_feature_dsl_spec.rb +0 -113
- data/spec/select_scen_outline_dsl_spec.rb +0 -233
- data/spec/select_scenario_dsl_spec.rb +0 -131
- data/spec/spec_helper.rb +0 -31
- data/spec/tag_filterable_specs.rb +0 -106
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for 'a line count filterable target set' do |target_type, test_data|
|
4
|
-
|
5
|
-
describe 'line count filters' do
|
6
|
-
|
7
|
-
|
8
|
-
it "should filter based on 'lc lt'" do
|
9
|
-
gs = CQL::Repository.new(test_data[:lc_lt][:fixture_location])
|
10
|
-
|
11
|
-
expected_results = test_data[:lc_lt][:expected_results]
|
12
|
-
|
13
|
-
expected_results.each do |number, expected|
|
14
|
-
result = gs.query do
|
15
|
-
select name
|
16
|
-
from target_type
|
17
|
-
with lc lt number
|
18
|
-
end
|
19
|
-
|
20
|
-
expect(result).to match_array(expected)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should filter based on 'lc_lte'" do
|
25
|
-
gs = CQL::Repository.new(test_data[:lc_lte][:fixture_location])
|
26
|
-
|
27
|
-
expected_results = test_data[:lc_lte][:expected_results]
|
28
|
-
|
29
|
-
expected_results.each do |number, expected|
|
30
|
-
result = gs.query do
|
31
|
-
select name
|
32
|
-
from target_type
|
33
|
-
with lc lte number
|
34
|
-
end
|
35
|
-
|
36
|
-
expect(result).to match_array(expected)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should filter based on 'lc_gt'" do
|
41
|
-
gs = CQL::Repository.new(test_data[:lc_gt][:fixture_location])
|
42
|
-
|
43
|
-
expected_results = test_data[:lc_gt][:expected_results]
|
44
|
-
|
45
|
-
expected_results.each do |number, expected|
|
46
|
-
result = gs.query do
|
47
|
-
select name
|
48
|
-
from target_type
|
49
|
-
with lc gt number
|
50
|
-
end
|
51
|
-
|
52
|
-
expect(result).to match_array(expected)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should filter based on 'lc_gte'" do
|
57
|
-
gs = CQL::Repository.new(test_data[:lc_gte][:fixture_location])
|
58
|
-
|
59
|
-
expected_results = test_data[:lc_gte][:expected_results]
|
60
|
-
|
61
|
-
expected_results.each do |number, expected|
|
62
|
-
result = gs.query do
|
63
|
-
select name
|
64
|
-
from target_type
|
65
|
-
with lc gte number
|
66
|
-
end
|
67
|
-
|
68
|
-
expect(result).to match_array(expected)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for 'a line filterable target set' do |target_type, test_data|
|
4
|
-
|
5
|
-
describe 'line match filters' do
|
6
|
-
|
7
|
-
it 'should filter by exact line' do
|
8
|
-
gs = CQL::Repository.new(test_data[:exact_line][:fixture_location])
|
9
|
-
|
10
|
-
expected_results = test_data[:exact_line][:expected_results]
|
11
|
-
|
12
|
-
expected_results.each do |matched_line, expected|
|
13
|
-
result = gs.query do
|
14
|
-
select name
|
15
|
-
from target_type
|
16
|
-
with line matched_line
|
17
|
-
end
|
18
|
-
|
19
|
-
expect(result).to eq(expected)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should filter by regexp' do
|
24
|
-
gs = CQL::Repository.new(test_data[:regexp][:fixture_location])
|
25
|
-
|
26
|
-
expected_results = test_data[:regexp][:expected_results]
|
27
|
-
|
28
|
-
expected_results.each do |matched_line, expected|
|
29
|
-
result = gs.query do
|
30
|
-
select name
|
31
|
-
from target_type
|
32
|
-
with line matched_line
|
33
|
-
end
|
34
|
-
|
35
|
-
expect(result).to eq(expected)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'can only handle a string or regular expression' do
|
40
|
-
gs = CQL::Repository.new(@feature_fixtures_directory)
|
41
|
-
|
42
|
-
expect { gs.query do
|
43
|
-
select name
|
44
|
-
from scenarios
|
45
|
-
with line 7
|
46
|
-
end }.to raise_error(ArgumentError, "Can only match a String or Regexp. Got Fixnum.")
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
data/spec/map_reduce_spec.rb
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "cql" do
|
4
|
-
|
5
|
-
# describe "file parsing" do
|
6
|
-
# it 'should find the physical files' do
|
7
|
-
# skip("This is possibly no longer be needed")
|
8
|
-
#
|
9
|
-
# gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
|
10
|
-
# result = CQL::MapReduce.uri(gs.parsed_feature_files)
|
11
|
-
#
|
12
|
-
# expect(result[0]).to match(/simple\.feature/)
|
13
|
-
# expect(result[1]).to match(/test\.feature/)
|
14
|
-
# expect(result[2]).to match(/test2\.feature/)
|
15
|
-
# expect(result[3]).to match(/test_full\.feature/)
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
|
19
|
-
#it 'should filter by count functions' do
|
20
|
-
# input = [{"keyword"=>"Feature", "name"=>"f1_4_scenarios_5_so", "line"=>1, "description"=>"", "id"=>"f1-4-scenarios-5-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f1_4_scenarios_5_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f1_scen1", "line"=>3, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f1_scen2", "line"=>7, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f1_scen3", "line"=>11, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario", "name"=>"f1_scen4", "line"=>15, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-scen4", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>16}, {"keyword"=>"Then ", "name"=>"something else", "line"=>17}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so1", "line"=>19, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>20}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>22, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so1;", "rows"=>[{"cells"=>["e"], "line"=>23, "id"=>"f1-4-scenarios-5-so;f1-so1;;1"}, {"cells"=>["r"], "line"=>24, "id"=>"f1-4-scenarios-5-so;f1-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so2", "line"=>26, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>27}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>29, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so2;", "rows"=>[{"cells"=>["e"], "line"=>30, "id"=>"f1-4-scenarios-5-so;f1-so2;;1"}, {"cells"=>["r"], "line"=>31, "id"=>"f1-4-scenarios-5-so;f1-so2;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so3", "line"=>33, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so3", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>34}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>36, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so3;", "rows"=>[{"cells"=>["e"], "line"=>37, "id"=>"f1-4-scenarios-5-so;f1-so3;;1"}, {"cells"=>["r"], "line"=>38, "id"=>"f1-4-scenarios-5-so;f1-so3;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so4", "line"=>40, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so4", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>41}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>43, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so4;", "rows"=>[{"cells"=>["e"], "line"=>44, "id"=>"f1-4-scenarios-5-so;f1-so4;;1"}, {"cells"=>["r"], "line"=>45, "id"=>"f1-4-scenarios-5-so;f1-so4;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f1_so5", "line"=>47, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so5", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>48}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>50, "description"=>"", "id"=>"f1-4-scenarios-5-so;f1-so5;", "rows"=>[{"cells"=>["e"], "line"=>51, "id"=>"f1-4-scenarios-5-so;f1-so5;;1"}, {"cells"=>["r"], "line"=>52, "id"=>"f1-4-scenarios-5-so;f1-so5;;2"}]}]}]},
|
21
|
-
# {"keyword"=>"Feature", "name"=>"f2_7_scenarios_2_so", "line"=>1, "description"=>"", "id"=>"f2-7-scenarios-2-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f2_7_scenarios_2_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f2_scen1", "line"=>3, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f2_scen2", "line"=>7, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f2_scen3", "line"=>11, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario", "name"=>"f2_scen4", "line"=>15, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen4", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>16}, {"keyword"=>"Then ", "name"=>"something else", "line"=>17}]}, {"keyword"=>"Scenario", "name"=>"f2_scen5", "line"=>19, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen5", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>20}, {"keyword"=>"Then ", "name"=>"something else", "line"=>21}]}, {"keyword"=>"Scenario", "name"=>"f2_scen6", "line"=>23, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen6", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>24}, {"keyword"=>"Then ", "name"=>"something else", "line"=>25}]}, {"keyword"=>"Scenario", "name"=>"f2_scen7", "line"=>27, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-scen7", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>28}, {"keyword"=>"Then ", "name"=>"something else", "line"=>29}]}, {"keyword"=>"Scenario Outline", "name"=>"f2_so1", "line"=>31, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>32}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>34, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so1;", "rows"=>[{"cells"=>["e"], "line"=>35, "id"=>"f2-7-scenarios-2-so;f2-so1;;1"}, {"cells"=>["r"], "line"=>36, "id"=>"f2-7-scenarios-2-so;f2-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f2_so2", "line"=>38, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>39}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>41, "description"=>"", "id"=>"f2-7-scenarios-2-so;f2-so2;", "rows"=>[{"cells"=>["e"], "line"=>42, "id"=>"f2-7-scenarios-2-so;f2-so2;;1"}, {"cells"=>["r"], "line"=>43}]}]}]},
|
22
|
-
# {"keyword"=>"Feature", "name"=>"f3_2_scenarios_3_so", "line"=>1, "description"=>"", "id"=>"f3-2-scenarios-3-so", "uri"=>"C:/Users/jarrod/dev/gql/spec/../fixtures/features/combined/a/f3_2_scenarios_3_so.feature", "elements"=>[{"keyword"=>"Scenario", "name"=>"f3_scen1", "line"=>3, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen1", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4}, {"keyword"=>"Then ", "name"=>"something else", "line"=>5}]}, {"keyword"=>"Scenario", "name"=>"f3_scen2", "line"=>7, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen2", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>8}, {"keyword"=>"Then ", "name"=>"something else", "line"=>9}]}, {"keyword"=>"Scenario", "name"=>"f3_scen3", "line"=>11, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-scen3", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>12}, {"keyword"=>"Then ", "name"=>"something else", "line"=>13}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so1", "line"=>15, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so1", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>16}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>18, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so1;", "rows"=>[{"cells"=>["e"], "line"=>19, "id"=>"f3-2-scenarios-3-so;f3-so1;;1"}, {"cells"=>["r"], "line"=>20, "id"=>"f3-2-scenarios-3-so;f3-so1;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so2", "line"=>22, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so2", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>23}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>25, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so2;", "rows"=>[{"cells"=>["e"], "line"=>26, "id"=>"f3-2-scenarios-3-so;f3-so2;;1"}, {"cells"=>["r"], "line"=>27, "id"=>"f3-2-scenarios-3-so;f3-so2;;2"}]}]}, {"keyword"=>"Scenario Outline", "name"=>"f3_so3", "line"=>29, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so3", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"blah <e>", "line"=>30}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>32, "description"=>"", "id"=>"f3-2-scenarios-3-so;f3-so3;", "rows"=>[{"cells"=>["e"], "line"=>33, "id"=>"f3-2-scenarios-3-so;f3-so3;;1"}, {"cells"=>["r"], "line"=>34, "id"=>"f3-2-scenarios-3-so;f3-so3;;2"}]}]}]}]
|
23
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>2})
|
24
|
-
# result.size.should == 3
|
25
|
-
#
|
26
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>0})
|
27
|
-
# result.size.should == 3
|
28
|
-
#
|
29
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>3})
|
30
|
-
# result.size.should == 2
|
31
|
-
#
|
32
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>7})
|
33
|
-
# result.size.should == 0
|
34
|
-
#
|
35
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>4})
|
36
|
-
# result.size.should == 1
|
37
|
-
#end
|
38
|
-
|
39
|
-
describe 'filter by tag count' do
|
40
|
-
#it 'should filter by tag count' do
|
41
|
-
# input = [
|
42
|
-
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
43
|
-
# "elements"=>[
|
44
|
-
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
45
|
-
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
46
|
-
# {"keyword"=>"Feature", "name"=>"Simple2", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[
|
47
|
-
# {"keyword"=>"Scenario", "name"=>"3 tags", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}, {"name"=>"@two", "line"=>3}, {"name"=>"@three", "line"=>3}], "id"=>"simple;3-tags", "type"=>"scenario"},
|
48
|
-
# {"keyword"=>"Scenario", "name"=>"4 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}, {"name"=>"@three", "line"=>11}, {"name"=>"@four", "line"=>11}], "id"=>"simple;4-tags", "type"=>"scenario", }]}
|
49
|
-
# ]
|
50
|
-
#
|
51
|
-
# expected = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
52
|
-
# "elements"=>[
|
53
|
-
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
54
|
-
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
55
|
-
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[]}]
|
56
|
-
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).size.should == expected.size
|
57
|
-
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).first['elements'].size.should == expected.first['elements'].size
|
58
|
-
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3})[1]['elements'].size.should == expected[1]['elements'].size
|
59
|
-
#
|
60
|
-
#end
|
61
|
-
end
|
62
|
-
|
63
|
-
#describe "tags" do
|
64
|
-
# it "retrieve tags from a scenario" do
|
65
|
-
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tags2"
|
66
|
-
# CQL::MapReduce.tag_set(gs.parsed_feature_files).sort.should == ["@five", "@four", "@one", "@two"].sort
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# it 'should filter features by tag' do
|
70
|
-
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"simple", "uri"=>"/a/a"},
|
71
|
-
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
72
|
-
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>1, "description"=>"", "id"=>"test2-feature"},
|
73
|
-
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test3-feature"}]
|
74
|
-
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one'])
|
75
|
-
# result.size.should == 2
|
76
|
-
# result[0]['name'].should == "Test Feature"
|
77
|
-
# result[1]['name'].should == "Test3 Feature"
|
78
|
-
# end
|
79
|
-
#
|
80
|
-
# it 'should filter by multiple tags' do
|
81
|
-
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple"},
|
82
|
-
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
83
|
-
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"test2-feature"},
|
84
|
-
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}], "id"=>"test3-feature"}]
|
85
|
-
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one', '@two'])
|
86
|
-
# result.should == [{"keyword"=>"Feature", "name"=>"Test3 Feature",
|
87
|
-
# "line"=>2, "description"=>"",
|
88
|
-
# "tags"=>[{"name"=>"@one", "line"=>1},
|
89
|
-
# {"name"=>"@two", "line"=>1}],
|
90
|
-
# "id"=>"test3-feature"}]
|
91
|
-
# end
|
92
|
-
#end
|
93
|
-
|
94
|
-
describe 'features query' do
|
95
|
-
#it 'should find all feature names' do
|
96
|
-
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
97
|
-
# CQL::MapReduce.name(gs.parsed_feature_files).should eql ["Simple", "Test Feature", "Test2 Feature", "Test3 Feature"]
|
98
|
-
#end
|
99
|
-
|
100
|
-
#it 'should retrieve a full feature' do
|
101
|
-
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
|
102
|
-
# result = CQL::MapReduce.filter_features(gs.parsed_feature_files, {'feature'=>["Test Feature"]})
|
103
|
-
# result[0]['name'].should == "Test Feature"
|
104
|
-
# result[0]['elements'][0]['name'].should == "Testing the slurping 1"
|
105
|
-
# result[0]['elements'].should == [{"keyword"=>"Scenario", "name"=>"Testing the slurping 1", "line"=>3,
|
106
|
-
# "description"=>"", "id"=>"test-feature;testing-the-slurping-1", "type"=>"scenario",
|
107
|
-
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
|
108
|
-
# {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}]},
|
109
|
-
# {"keyword"=>"Scenario", "name"=>"Testing the slurping not to be found", "line"=>7,
|
110
|
-
# "description"=>"", "id"=>"test-feature;testing-the-slurping-not-to-be-found", "type"=>"scenario",
|
111
|
-
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>8}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>9}]}]
|
112
|
-
#end
|
113
|
-
end
|
114
|
-
|
115
|
-
#describe 'scenario query' do
|
116
|
-
# it 'should get all scenarios as a list' do
|
117
|
-
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
118
|
-
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=>'scenario'})
|
119
|
-
# result.should == [{"keyword"=>"Scenario", "name"=>"A Scenario", "line"=>13, "description"=>"", "id"=>"test-feature;a-scenario", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>14}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>15}]}]
|
120
|
-
# end
|
121
|
-
#end
|
122
|
-
#
|
123
|
-
#describe 'scenario outline query' do
|
124
|
-
# it 'should get scenario outlines as a list' do
|
125
|
-
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
126
|
-
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=> 'scenario'})
|
127
|
-
# result.should == [{"keyword"=>"Scenario", "name"=>"A Scenario", "line"=>13, "description"=>"", "id"=>"test-feature;a-scenario", "type"=>"scenario", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>14}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>15}]}]
|
128
|
-
#
|
129
|
-
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=> ["Test Feature"], 'what'=> 'scenario_outline'})
|
130
|
-
# result.should == [{"keyword"=>"Scenario Outline", "name"=>"An Outline", "line"=>3, "description"=>"", "id"=>"test-feature;an-outline", "type"=>"scenario_outline", "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}], "examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;", "rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"}, {"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"}, {"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"}, {"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"}, {"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]}]}]
|
131
|
-
# end
|
132
|
-
#end
|
133
|
-
|
134
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "cql" do
|
4
|
-
|
5
|
-
describe 'repo' do
|
6
|
-
it 'should not change between queries' do
|
7
|
-
|
8
|
-
repo = CQL::Repository.new("#{@feature_fixtures_directory}/got")
|
9
|
-
|
10
|
-
before_dump = Marshal.dump(repo)
|
11
|
-
|
12
|
-
repo.query do
|
13
|
-
select name
|
14
|
-
from scenarios
|
15
|
-
end
|
16
|
-
|
17
|
-
after_dump = Marshal.dump(repo)
|
18
|
-
|
19
|
-
|
20
|
-
expect(before_dump).to eq(after_dump)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for 'a name filterable target set' do |target_type, test_data|
|
4
|
-
|
5
|
-
describe 'name filters' do
|
6
|
-
|
7
|
-
it 'should filter by exact name' do
|
8
|
-
gs = CQL::Repository.new(test_data[:exact_name][:fixture_location])
|
9
|
-
|
10
|
-
expected_results = test_data[:exact_name][:expected_results]
|
11
|
-
|
12
|
-
expected_results.each do |matched_name, expected|
|
13
|
-
result = gs.query do
|
14
|
-
select name
|
15
|
-
from target_type
|
16
|
-
with name matched_name
|
17
|
-
end
|
18
|
-
|
19
|
-
expect(result).to eq(expected)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should filter by regexp' do
|
24
|
-
gs = CQL::Repository.new(test_data[:regexp][:fixture_location])
|
25
|
-
|
26
|
-
expected_results = test_data[:regexp][:expected_results]
|
27
|
-
|
28
|
-
expected_results.each do |matched_name, expected|
|
29
|
-
result = gs.query do
|
30
|
-
select name
|
31
|
-
from target_type
|
32
|
-
with name matched_name
|
33
|
-
end
|
34
|
-
|
35
|
-
expect(result).to match_array(expected)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'can only handle a string or regular expression' do
|
40
|
-
gs = CQL::Repository.new(@feature_fixtures_directory)
|
41
|
-
|
42
|
-
expect { gs.query do
|
43
|
-
select name
|
44
|
-
from scenarios
|
45
|
-
with name 7
|
46
|
-
end }.to raise_error(ArgumentError, "Can only match a String or Regexp. Got Fixnum.")
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
data/spec/repository_spec.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'CQL::Repository' do
|
4
|
-
|
5
|
-
clazz = CQL::Repository
|
6
|
-
|
7
|
-
it 'can be made from a file path' do
|
8
|
-
expect { clazz.new(@feature_fixtures_directory) }.to_not raise_error
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'can be made from a model' do
|
12
|
-
some_model = CukeModeler::Scenario.new
|
13
|
-
|
14
|
-
expect { clazz.new(some_model) }.to_not raise_error
|
15
|
-
end
|
16
|
-
|
17
|
-
it "complains if can't be made from what it was given" do
|
18
|
-
expect { clazz.new(:some_other_thing) }.to raise_error(ArgumentError, "Don't know how to make a repository from a Symbol")
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "select" do
|
4
|
-
describe "from features" do
|
5
|
-
|
6
|
-
it 'should return names from features' do
|
7
|
-
gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
|
8
|
-
|
9
|
-
result = gs.query do
|
10
|
-
select name
|
11
|
-
from features
|
12
|
-
end
|
13
|
-
|
14
|
-
expect(result).to match_array([{"name" => "Simple"}, {"name" => "Test Feature"},
|
15
|
-
{"name" => "Test2 Feature"}, {"name" => "Test3 Feature"}])
|
16
|
-
end
|
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
|
28
|
-
|
29
|
-
it 'should return paths from from feature files' do
|
30
|
-
repo_path = "#{@feature_fixtures_directory}/scenario/simple"
|
31
|
-
gs = CQL::Repository.new(repo_path)
|
32
|
-
|
33
|
-
result = gs.query do
|
34
|
-
select path
|
35
|
-
from feature_files
|
36
|
-
end
|
37
|
-
|
38
|
-
expect(result).to match_array([{'path' => "#{repo_path}/simple.feature"},
|
39
|
-
{'path' => "#{repo_path}/test.feature"},
|
40
|
-
{'path' => "#{repo_path}/test2.feature"},
|
41
|
-
{'path' => "#{repo_path}/test_full.feature"}])
|
42
|
-
end
|
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
|
72
|
-
|
73
|
-
it 'should return things from multiple feature files' do
|
74
|
-
gr = CQL::Repository.new("#{@feature_fixtures_directory}/combined/b")
|
75
|
-
|
76
|
-
result = gr.query do
|
77
|
-
select name
|
78
|
-
from features
|
79
|
-
end
|
80
|
-
|
81
|
-
expect(result).to match_array([{"name" => "f1_1_tag"},
|
82
|
-
{"name" => "f2_2_tags"},
|
83
|
-
{"name" => "f3_3_tags"}])
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should return multiple features as a list of maps' do
|
87
|
-
gr = CQL::Repository.new("#{@feature_fixtures_directory}/combined/b")
|
88
|
-
|
89
|
-
result = gr.query do
|
90
|
-
select name
|
91
|
-
from features
|
92
|
-
end
|
93
|
-
|
94
|
-
expect(result).to match_array([{"name" => "f1_1_tag"},
|
95
|
-
{"name" => "f2_2_tags"},
|
96
|
-
{"name" => "f3_3_tags"}])
|
97
|
-
end
|
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
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|