cql 0.1.9 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cql.rb +62 -62
- data/lib/dsl.rb +110 -110
- data/lib/feature_filters.rb +72 -72
- data/lib/map_reduce.rb +39 -39
- data/lib/sso_filters.rb +72 -72
- data/spec/filter_feature_dsl_spec.rb +485 -485
- data/spec/filter_sso_spec.rb +287 -287
- data/spec/map_reduce_spec.rb +131 -131
- data/spec/select_feature_dsl_spec.rb +49 -49
- data/spec/select_scen_outline_dsl_spec.rb +125 -125
- data/spec/select_scenario_dsl_spec.rb +72 -72
- data/spec/unit_spec.rb +21 -21
- metadata +3 -3
data/spec/map_reduce_spec.rb
CHANGED
@@ -1,132 +1,132 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require File.dirname(__FILE__) + "/../lib/cql"
|
3
|
-
|
4
|
-
describe "cql" do
|
5
|
-
|
6
|
-
describe "file parsing" do
|
7
|
-
it 'should find the physical files' do
|
8
|
-
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
9
|
-
result = CQL::MapReduce.uri(gs.parsed_feature_files)
|
10
|
-
result[0].should =~ /simple\.feature/
|
11
|
-
result[1].should =~ /test\.feature/
|
12
|
-
result[2].should =~ /test2\.feature/
|
13
|
-
result[3].should =~ /test_full\.feature/
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
#it 'should filter by count functions' do
|
18
|
-
# 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"}]}]}]},
|
19
|
-
# {"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}]}]}]},
|
20
|
-
# {"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"}]}]}]}]
|
21
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>2})
|
22
|
-
# result.size.should == 3
|
23
|
-
#
|
24
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>0})
|
25
|
-
# result.size.should == 3
|
26
|
-
#
|
27
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>3})
|
28
|
-
# result.size.should == 2
|
29
|
-
#
|
30
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>7})
|
31
|
-
# result.size.should == 0
|
32
|
-
#
|
33
|
-
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>4})
|
34
|
-
# result.size.should == 1
|
35
|
-
#end
|
36
|
-
|
37
|
-
describe 'filter by tag count' do
|
38
|
-
#it 'should filter by tag count' do
|
39
|
-
# input = [
|
40
|
-
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
41
|
-
# "elements"=>[
|
42
|
-
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
43
|
-
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
44
|
-
# {"keyword"=>"Feature", "name"=>"Simple2", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[
|
45
|
-
# {"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"},
|
46
|
-
# {"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", }]}
|
47
|
-
# ]
|
48
|
-
#
|
49
|
-
# expected = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
50
|
-
# "elements"=>[
|
51
|
-
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
52
|
-
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
53
|
-
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[]}]
|
54
|
-
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).size.should == expected.size
|
55
|
-
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).first['elements'].size.should == expected.first['elements'].size
|
56
|
-
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3})[1]['elements'].size.should == expected[1]['elements'].size
|
57
|
-
#
|
58
|
-
#end
|
59
|
-
end
|
60
|
-
|
61
|
-
#describe "tags" do
|
62
|
-
# it "retrieve tags from a scenario" do
|
63
|
-
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tags2"
|
64
|
-
# CQL::MapReduce.tag_set(gs.parsed_feature_files).sort.should == ["@five", "@four", "@one", "@two"].sort
|
65
|
-
# end
|
66
|
-
#
|
67
|
-
# it 'should filter features by tag' do
|
68
|
-
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"simple", "uri"=>"/a/a"},
|
69
|
-
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
70
|
-
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>1, "description"=>"", "id"=>"test2-feature"},
|
71
|
-
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test3-feature"}]
|
72
|
-
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one'])
|
73
|
-
# result.size.should == 2
|
74
|
-
# result[0]['name'].should == "Test Feature"
|
75
|
-
# result[1]['name'].should == "Test3 Feature"
|
76
|
-
# end
|
77
|
-
#
|
78
|
-
# it 'should filter by multiple tags' do
|
79
|
-
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple"},
|
80
|
-
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
81
|
-
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"test2-feature"},
|
82
|
-
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}], "id"=>"test3-feature"}]
|
83
|
-
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one', '@two'])
|
84
|
-
# result.should == [{"keyword"=>"Feature", "name"=>"Test3 Feature",
|
85
|
-
# "line"=>2, "description"=>"",
|
86
|
-
# "tags"=>[{"name"=>"@one", "line"=>1},
|
87
|
-
# {"name"=>"@two", "line"=>1}],
|
88
|
-
# "id"=>"test3-feature"}]
|
89
|
-
# end
|
90
|
-
#end
|
91
|
-
|
92
|
-
describe 'features query' do
|
93
|
-
#it 'should find all feature names' do
|
94
|
-
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
95
|
-
# CQL::MapReduce.name(gs.parsed_feature_files).should eql ["Simple", "Test Feature", "Test2 Feature", "Test3 Feature"]
|
96
|
-
#end
|
97
|
-
|
98
|
-
#it 'should retrieve a full feature' do
|
99
|
-
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
|
100
|
-
# result = CQL::MapReduce.filter_features(gs.parsed_feature_files, {'feature'=>["Test Feature"]})
|
101
|
-
# result[0]['name'].should == "Test Feature"
|
102
|
-
# result[0]['elements'][0]['name'].should == "Testing the slurping 1"
|
103
|
-
# result[0]['elements'].should == [{"keyword"=>"Scenario", "name"=>"Testing the slurping 1", "line"=>3,
|
104
|
-
# "description"=>"", "id"=>"test-feature;testing-the-slurping-1", "type"=>"scenario",
|
105
|
-
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
|
106
|
-
# {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}]},
|
107
|
-
# {"keyword"=>"Scenario", "name"=>"Testing the slurping not to be found", "line"=>7,
|
108
|
-
# "description"=>"", "id"=>"test-feature;testing-the-slurping-not-to-be-found", "type"=>"scenario",
|
109
|
-
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>8}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>9}]}]
|
110
|
-
#end
|
111
|
-
end
|
112
|
-
|
113
|
-
#describe 'scenario query' do
|
114
|
-
# it 'should get all scenarios as a list' do
|
115
|
-
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
116
|
-
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=>'scenario'})
|
117
|
-
# 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}]}]
|
118
|
-
# end
|
119
|
-
#end
|
120
|
-
#
|
121
|
-
#describe 'scenario outline query' do
|
122
|
-
# it 'should get scenario outlines as a list' do
|
123
|
-
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
124
|
-
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=> 'scenario'})
|
125
|
-
# 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}]}]
|
126
|
-
#
|
127
|
-
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=> ["Test Feature"], 'what'=> 'scenario_outline'})
|
128
|
-
# 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"}]}]}]
|
129
|
-
# end
|
130
|
-
#end
|
131
|
-
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/cql"
|
3
|
+
|
4
|
+
describe "cql" do
|
5
|
+
|
6
|
+
describe "file parsing" do
|
7
|
+
it 'should find the physical files' do
|
8
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
9
|
+
result = CQL::MapReduce.uri(gs.parsed_feature_files)
|
10
|
+
result[0].should =~ /simple\.feature/
|
11
|
+
result[1].should =~ /test\.feature/
|
12
|
+
result[2].should =~ /test2\.feature/
|
13
|
+
result[3].should =~ /test_full\.feature/
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
#it 'should filter by count functions' do
|
18
|
+
# 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"}]}]}]},
|
19
|
+
# {"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}]}]}]},
|
20
|
+
# {"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"}]}]}]}]
|
21
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>2})
|
22
|
+
# result.size.should == 3
|
23
|
+
#
|
24
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>0})
|
25
|
+
# result.size.should == 3
|
26
|
+
#
|
27
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>3})
|
28
|
+
# result.size.should == 2
|
29
|
+
#
|
30
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>7})
|
31
|
+
# result.size.should == 0
|
32
|
+
#
|
33
|
+
# result = CQL::MapReduce.filter_features(input, {'sc_gt'=>4})
|
34
|
+
# result.size.should == 1
|
35
|
+
#end
|
36
|
+
|
37
|
+
describe 'filter by tag count' do
|
38
|
+
#it 'should filter by tag count' do
|
39
|
+
# input = [
|
40
|
+
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
41
|
+
# "elements"=>[
|
42
|
+
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
43
|
+
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
44
|
+
# {"keyword"=>"Feature", "name"=>"Simple2", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[
|
45
|
+
# {"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"},
|
46
|
+
# {"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", }]}
|
47
|
+
# ]
|
48
|
+
#
|
49
|
+
# expected = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"",
|
50
|
+
# "elements"=>[
|
51
|
+
# {"keyword"=>"Scenario", "name"=>"1 tag", "line"=>4, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>3}], "id"=>"simple;1-tag", "type"=>"scenario"},
|
52
|
+
# {"keyword"=>"Scenario", "name"=>"2 tags", "line"=>12, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>11}, {"name"=>"@two", "line"=>11}], "id"=>"simple;2-tags", "type"=>"scenario"}]},
|
53
|
+
# {"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple", "uri"=>"", "elements"=>[]}]
|
54
|
+
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).size.should == expected.size
|
55
|
+
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3}).first['elements'].size.should == expected.first['elements'].size
|
56
|
+
# CQL::MapReduce.filter_sso2(input, {"tc_lt"=>3})[1]['elements'].size.should == expected[1]['elements'].size
|
57
|
+
#
|
58
|
+
#end
|
59
|
+
end
|
60
|
+
|
61
|
+
#describe "tags" do
|
62
|
+
# it "retrieve tags from a scenario" do
|
63
|
+
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tags2"
|
64
|
+
# CQL::MapReduce.tag_set(gs.parsed_feature_files).sort.should == ["@five", "@four", "@one", "@two"].sort
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# it 'should filter features by tag' do
|
68
|
+
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"simple", "uri"=>"/a/a"},
|
69
|
+
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
70
|
+
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>1, "description"=>"", "id"=>"test2-feature"},
|
71
|
+
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test3-feature"}]
|
72
|
+
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one'])
|
73
|
+
# result.size.should == 2
|
74
|
+
# result[0]['name'].should == "Test Feature"
|
75
|
+
# result[1]['name'].should == "Test3 Feature"
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# it 'should filter by multiple tags' do
|
79
|
+
# input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "id"=>"simple"},
|
80
|
+
# {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
|
81
|
+
# {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"test2-feature"},
|
82
|
+
# {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}], "id"=>"test3-feature"}]
|
83
|
+
# result = CQL::MapReduce.filter_features(input, 'tags'=>['@one', '@two'])
|
84
|
+
# result.should == [{"keyword"=>"Feature", "name"=>"Test3 Feature",
|
85
|
+
# "line"=>2, "description"=>"",
|
86
|
+
# "tags"=>[{"name"=>"@one", "line"=>1},
|
87
|
+
# {"name"=>"@two", "line"=>1}],
|
88
|
+
# "id"=>"test3-feature"}]
|
89
|
+
# end
|
90
|
+
#end
|
91
|
+
|
92
|
+
describe 'features query' do
|
93
|
+
#it 'should find all feature names' do
|
94
|
+
# gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
95
|
+
# CQL::MapReduce.name(gs.parsed_feature_files).should eql ["Simple", "Test Feature", "Test2 Feature", "Test3 Feature"]
|
96
|
+
#end
|
97
|
+
|
98
|
+
#it 'should retrieve a full feature' do
|
99
|
+
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
|
100
|
+
# result = CQL::MapReduce.filter_features(gs.parsed_feature_files, {'feature'=>["Test Feature"]})
|
101
|
+
# result[0]['name'].should == "Test Feature"
|
102
|
+
# result[0]['elements'][0]['name'].should == "Testing the slurping 1"
|
103
|
+
# result[0]['elements'].should == [{"keyword"=>"Scenario", "name"=>"Testing the slurping 1", "line"=>3,
|
104
|
+
# "description"=>"", "id"=>"test-feature;testing-the-slurping-1", "type"=>"scenario",
|
105
|
+
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
|
106
|
+
# {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}]},
|
107
|
+
# {"keyword"=>"Scenario", "name"=>"Testing the slurping not to be found", "line"=>7,
|
108
|
+
# "description"=>"", "id"=>"test-feature;testing-the-slurping-not-to-be-found", "type"=>"scenario",
|
109
|
+
# "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>8}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>9}]}]
|
110
|
+
#end
|
111
|
+
end
|
112
|
+
|
113
|
+
#describe 'scenario query' do
|
114
|
+
# it 'should get all scenarios as a list' do
|
115
|
+
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
116
|
+
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=>'scenario'})
|
117
|
+
# 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}]}]
|
118
|
+
# end
|
119
|
+
#end
|
120
|
+
#
|
121
|
+
#describe 'scenario outline query' do
|
122
|
+
# it 'should get scenario outlines as a list' do
|
123
|
+
# gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
124
|
+
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=>["Test Feature"], 'what'=> 'scenario'})
|
125
|
+
# 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}]}]
|
126
|
+
#
|
127
|
+
# result = CQL::MapReduce.filter_sso(gs.parsed_feature_files, {'feature'=> ["Test Feature"], 'what'=> 'scenario_outline'})
|
128
|
+
# 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"}]}]}]
|
129
|
+
# end
|
130
|
+
#end
|
131
|
+
|
132
132
|
end
|
@@ -1,50 +1,50 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require File.dirname(__FILE__) + "/../lib/cql"
|
3
|
-
|
4
|
-
describe "select" do
|
5
|
-
describe "feature" do
|
6
|
-
it 'should return multiple feature file names' do
|
7
|
-
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
8
|
-
result = gs.query do
|
9
|
-
select name
|
10
|
-
from features
|
11
|
-
end
|
12
|
-
result.should == [{"name"=>"Simple"}, {"name"=>"Test Feature"},
|
13
|
-
{"name"=>"Test2 Feature"}, {"name"=>"Test3 Feature"}]
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should find the feature description' do
|
17
|
-
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple2"
|
18
|
-
result = gs.query do
|
19
|
-
select description
|
20
|
-
from features
|
21
|
-
end
|
22
|
-
result.should == {"description"=>"The cat in the hat"}
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should find the feature file uri' do
|
26
|
-
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
27
|
-
result = gs.query do
|
28
|
-
select uri
|
29
|
-
from features
|
30
|
-
end
|
31
|
-
result[0]['uri'].should =~ /simple\.feature/
|
32
|
-
result[1]['uri'].should =~ /test\.feature/
|
33
|
-
result[2]['uri'].should =~ /test2\.feature/
|
34
|
-
result[3]['uri'].should =~ /test\_full\.feature/
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should return multiple feature file names with associated tags' do
|
38
|
-
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tagged_features"
|
39
|
-
result = gs.query do
|
40
|
-
select name, tags
|
41
|
-
from features
|
42
|
-
end
|
43
|
-
result.should == [{"name"=>"Simple", "tags"=>nil},
|
44
|
-
{"name"=>"Test Feature", "tags"=>[{"name"=>"@one", "line"=>1}]},
|
45
|
-
{"name"=>"Test2 Feature", "tags"=>[{"name"=>"@two", "line"=>1}]},
|
46
|
-
{"name"=>"Test3 Feature", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}]}]
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/cql"
|
3
|
+
|
4
|
+
describe "select" do
|
5
|
+
describe "feature" do
|
6
|
+
it 'should return multiple feature file names' do
|
7
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
8
|
+
result = gs.query do
|
9
|
+
select name
|
10
|
+
from features
|
11
|
+
end
|
12
|
+
result.should == [{"name"=>"Simple"}, {"name"=>"Test Feature"},
|
13
|
+
{"name"=>"Test2 Feature"}, {"name"=>"Test3 Feature"}]
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should find the feature description' do
|
17
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple2"
|
18
|
+
result = gs.query do
|
19
|
+
select description
|
20
|
+
from features
|
21
|
+
end
|
22
|
+
result.should == {"description"=>"The cat in the hat"}
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should find the feature file uri' do
|
26
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/simple"
|
27
|
+
result = gs.query do
|
28
|
+
select uri
|
29
|
+
from features
|
30
|
+
end
|
31
|
+
result[0]['uri'].should =~ /simple\.feature/
|
32
|
+
result[1]['uri'].should =~ /test\.feature/
|
33
|
+
result[2]['uri'].should =~ /test2\.feature/
|
34
|
+
result[3]['uri'].should =~ /test\_full\.feature/
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return multiple feature file names with associated tags' do
|
38
|
+
gs = CQL::Repository.new File.dirname(__FILE__) + "/../fixtures/features/scenario/tagged_features"
|
39
|
+
result = gs.query do
|
40
|
+
select name, tags
|
41
|
+
from features
|
42
|
+
end
|
43
|
+
result.should == [{"name"=>"Simple", "tags"=>nil},
|
44
|
+
{"name"=>"Test Feature", "tags"=>[{"name"=>"@one", "line"=>1}]},
|
45
|
+
{"name"=>"Test2 Feature", "tags"=>[{"name"=>"@two", "line"=>1}]},
|
46
|
+
{"name"=>"Test3 Feature", "tags"=>[{"name"=>"@one", "line"=>1}, {"name"=>"@two", "line"=>1}]}]
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
50
|
end
|
@@ -1,126 +1,126 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require File.dirname(__FILE__) + "/../lib/cql"
|
3
|
-
|
4
|
-
describe "select" do
|
5
|
-
describe "single value, single results" do
|
6
|
-
it 'should get scenario outlines line number' do
|
7
|
-
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
8
|
-
result = gs.query do
|
9
|
-
select line
|
10
|
-
from scenario_outlines
|
11
|
-
end
|
12
|
-
result.should == {"line"=>3}
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should get scenario outlines name' do
|
16
|
-
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
17
|
-
result = gs.query do
|
18
|
-
select name
|
19
|
-
from scenario_outlines
|
20
|
-
end
|
21
|
-
result.should == {"name"=> "An Outline"}
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return the examples used" do
|
25
|
-
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
26
|
-
result = gr.query do
|
27
|
-
select examples
|
28
|
-
from scenario_outlines
|
29
|
-
end
|
30
|
-
result.should == {"examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6,
|
31
|
-
"description"=>"", "id"=>"test-feature;an-outline;",
|
32
|
-
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"},
|
33
|
-
{"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"},
|
34
|
-
{"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"},
|
35
|
-
{"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"},
|
36
|
-
{"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]
|
37
|
-
}]}
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should return multiple examples used for a single scenario outline" do
|
41
|
-
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/multiple_examples"
|
42
|
-
result = gr.query do
|
43
|
-
select examples
|
44
|
-
from scenario_outlines
|
45
|
-
end
|
46
|
-
result.should == {"examples"=>[{"keyword"=>"Examples", "name"=>"One", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;one",
|
47
|
-
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;one;1"},
|
48
|
-
{"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;one;2"},
|
49
|
-
{"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;one;3"}]},
|
50
|
-
{"keyword"=>"Examples", "name"=>"Two", "line"=>11, "description"=>"", "id"=>"test-feature;an-outline;two",
|
51
|
-
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>12, "id"=>"test-feature;an-outline;two;1"},
|
52
|
-
{"cells"=>["1", "a"], "line"=>13, "id"=>"test-feature;an-outline;two;2"},
|
53
|
-
{"cells"=>["2", "b"], "line"=>14, "id"=>"test-feature;an-outline;two;3"}]}]}
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "single value, multiple results" do
|
59
|
-
it 'should get scenario outlines as is when no select criteria given' do
|
60
|
-
expected = {"all"=>{"keyword"=>"Scenario Outline",
|
61
|
-
"name"=>"An Outline",
|
62
|
-
"line"=>3, "description"=>"",
|
63
|
-
"id"=>"test-feature;an-outline", "type"=>"scenario_outline",
|
64
|
-
"steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
|
65
|
-
{"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}],
|
66
|
-
"examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;",
|
67
|
-
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"},
|
68
|
-
{"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"},
|
69
|
-
{"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"},
|
70
|
-
{"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"},
|
71
|
-
{"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]}]}}
|
72
|
-
|
73
|
-
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
74
|
-
result = gs.query do
|
75
|
-
select all
|
76
|
-
from scenario_outlines
|
77
|
-
end
|
78
|
-
result.should == expected
|
79
|
-
|
80
|
-
result = gs.query do
|
81
|
-
select everything
|
82
|
-
from scenario_outlines
|
83
|
-
end
|
84
|
-
result.should == expected
|
85
|
-
|
86
|
-
result = gs.query do
|
87
|
-
select complete
|
88
|
-
from scenario_outlines
|
89
|
-
end
|
90
|
-
result.should == expected
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "select all" do
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "special selectors" do
|
99
|
-
it 'should get the full step line scenario outlines' do
|
100
|
-
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
101
|
-
result = gs.query do
|
102
|
-
select step_lines
|
103
|
-
from scenario_outlines
|
104
|
-
end
|
105
|
-
result.should == {"step_lines"=> ["Given something happend", "Then I expect something else"]}
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "multiple values" do
|
110
|
-
it 'should get scenario outlines name and line numbers as a map' do
|
111
|
-
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
112
|
-
result = gs.query do
|
113
|
-
select name, line, type, step_lines, id, steps
|
114
|
-
from scenario_outlines
|
115
|
-
end
|
116
|
-
result.should == {'name'=>"An Outline",
|
117
|
-
'line'=>3,
|
118
|
-
'id'=>'test-feature;an-outline',
|
119
|
-
'type'=>'scenario_outline',
|
120
|
-
"steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}],
|
121
|
-
"step_lines"=>["Given something happend", "Then I expect something else"]
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/cql"
|
3
|
+
|
4
|
+
describe "select" do
|
5
|
+
describe "single value, single results" do
|
6
|
+
it 'should get scenario outlines line number' do
|
7
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
8
|
+
result = gs.query do
|
9
|
+
select line
|
10
|
+
from scenario_outlines
|
11
|
+
end
|
12
|
+
result.should == {"line"=>3}
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should get scenario outlines name' do
|
16
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
17
|
+
result = gs.query do
|
18
|
+
select name
|
19
|
+
from scenario_outlines
|
20
|
+
end
|
21
|
+
result.should == {"name"=> "An Outline"}
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the examples used" do
|
25
|
+
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
26
|
+
result = gr.query do
|
27
|
+
select examples
|
28
|
+
from scenario_outlines
|
29
|
+
end
|
30
|
+
result.should == {"examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6,
|
31
|
+
"description"=>"", "id"=>"test-feature;an-outline;",
|
32
|
+
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"},
|
33
|
+
{"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"},
|
34
|
+
{"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"},
|
35
|
+
{"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"},
|
36
|
+
{"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]
|
37
|
+
}]}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return multiple examples used for a single scenario outline" do
|
41
|
+
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/multiple_examples"
|
42
|
+
result = gr.query do
|
43
|
+
select examples
|
44
|
+
from scenario_outlines
|
45
|
+
end
|
46
|
+
result.should == {"examples"=>[{"keyword"=>"Examples", "name"=>"One", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;one",
|
47
|
+
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;one;1"},
|
48
|
+
{"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;one;2"},
|
49
|
+
{"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;one;3"}]},
|
50
|
+
{"keyword"=>"Examples", "name"=>"Two", "line"=>11, "description"=>"", "id"=>"test-feature;an-outline;two",
|
51
|
+
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>12, "id"=>"test-feature;an-outline;two;1"},
|
52
|
+
{"cells"=>["1", "a"], "line"=>13, "id"=>"test-feature;an-outline;two;2"},
|
53
|
+
{"cells"=>["2", "b"], "line"=>14, "id"=>"test-feature;an-outline;two;3"}]}]}
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "single value, multiple results" do
|
59
|
+
it 'should get scenario outlines as is when no select criteria given' do
|
60
|
+
expected = {"all"=>{"keyword"=>"Scenario Outline",
|
61
|
+
"name"=>"An Outline",
|
62
|
+
"line"=>3, "description"=>"",
|
63
|
+
"id"=>"test-feature;an-outline", "type"=>"scenario_outline",
|
64
|
+
"steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
|
65
|
+
{"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}],
|
66
|
+
"examples"=>[{"keyword"=>"Examples", "name"=>"", "line"=>6, "description"=>"", "id"=>"test-feature;an-outline;",
|
67
|
+
"rows"=>[{"cells"=>["var_a", "var_b"], "line"=>7, "id"=>"test-feature;an-outline;;1"},
|
68
|
+
{"cells"=>["1", "a"], "line"=>8, "id"=>"test-feature;an-outline;;2"},
|
69
|
+
{"cells"=>["2", "b"], "line"=>9, "id"=>"test-feature;an-outline;;3"},
|
70
|
+
{"cells"=>["3", "c"], "line"=>10, "id"=>"test-feature;an-outline;;4"},
|
71
|
+
{"cells"=>["4", "d"], "line"=>11, "id"=>"test-feature;an-outline;;5"}]}]}}
|
72
|
+
|
73
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
74
|
+
result = gs.query do
|
75
|
+
select all
|
76
|
+
from scenario_outlines
|
77
|
+
end
|
78
|
+
result.should == expected
|
79
|
+
|
80
|
+
result = gs.query do
|
81
|
+
select everything
|
82
|
+
from scenario_outlines
|
83
|
+
end
|
84
|
+
result.should == expected
|
85
|
+
|
86
|
+
result = gs.query do
|
87
|
+
select complete
|
88
|
+
from scenario_outlines
|
89
|
+
end
|
90
|
+
result.should == expected
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "select all" do
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "special selectors" do
|
99
|
+
it 'should get the full step line scenario outlines' do
|
100
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
101
|
+
result = gs.query do
|
102
|
+
select step_lines
|
103
|
+
from scenario_outlines
|
104
|
+
end
|
105
|
+
result.should == {"step_lines"=> ["Given something happend", "Then I expect something else"]}
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "multiple values" do
|
110
|
+
it 'should get scenario outlines name and line numbers as a map' do
|
111
|
+
gs = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines/basic"
|
112
|
+
result = gs.query do
|
113
|
+
select name, line, type, step_lines, id, steps
|
114
|
+
from scenario_outlines
|
115
|
+
end
|
116
|
+
result.should == {'name'=>"An Outline",
|
117
|
+
'line'=>3,
|
118
|
+
'id'=>'test-feature;an-outline',
|
119
|
+
'type'=>'scenario_outline',
|
120
|
+
"steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}],
|
121
|
+
"step_lines"=>["Given something happend", "Then I expect something else"]
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
126
|
end
|