cql 0.2.1 → 0.3.0

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.
@@ -0,0 +1,40 @@
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
+ end
40
+ end
@@ -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
-
132
- end
1
+ require 'spec_helper'
2
+
3
+ describe "cql" do
4
+
5
+ describe "file parsing" do
6
+ it 'should find the physical files' do
7
+ gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple")
8
+ result = CQL::MapReduce.uri(gs.parsed_feature_files)
9
+
10
+ expect(result[0]).to match(/simple\.feature/)
11
+ expect(result[1]).to match(/test\.feature/)
12
+ expect(result[2]).to match(/test2\.feature/)
13
+ expect(result[3]).to match(/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
+ end
@@ -0,0 +1,27 @@
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
+ result = repo.query do
11
+ select name
12
+ from scenarios
13
+ with tags '@Lannister'
14
+ end
15
+
16
+
17
+ result = repo.query do
18
+ select name
19
+ from scenarios
20
+ with line /child/
21
+ end
22
+
23
+ expect(result).to eq([{"name" => "Strange relations"},
24
+ {"name" => "Bastard Child"}])
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,40 @@
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 eq(expected)
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -1,50 +1,191 @@
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
- end
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 eq([{"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
23
+ from features
24
+ end
25
+
26
+ expect(result).to eq([{"description" => "The cat in the hat"}])
27
+ end
28
+
29
+ it 'should return uris from features' do
30
+ repo_path = "#{@feature_fixtures_directory}/scenario/simple"
31
+ gs = CQL::Repository.new(repo_path)
32
+
33
+ result = gs.query do
34
+ select uri
35
+ from features
36
+ end
37
+
38
+ expect(result[0]['uri']).to eq("#{repo_path}/simple.feature")
39
+ expect(result[1]['uri']).to eq("#{repo_path}/test.feature")
40
+ expect(result[2]['uri']).to eq("#{repo_path}/test2.feature")
41
+ expect(result[3]['uri']).to eq("#{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 eq([{"tags" => nil},
53
+ {"tags" => [{"name" => "@one", "line" => 1}]},
54
+ {"tags" => [{"name" => "@two", "line" => 1}]},
55
+ {"tags" => [{"name" => "@one", "line" => 1}, {"name" => "@two", "line" => 1}]}])
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 eq([{"name" => "Simple", "tags" => nil},
68
+ {"name" => "Test Feature", "tags" => [{"name" => "@one", "line" => 1}]},
69
+ {"name" => "Test2 Feature", "tags" => [{"name" => "@two", "line" => 1}]},
70
+ {"name" => "Test3 Feature", "tags" => [{"name" => "@one", "line" => 1}, {"name" => "@two", "line" => 1}]}])
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 eq([{"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 eq([{"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 id
104
+ from features
105
+ end
106
+
107
+ expect(result).to eq([{"id" => "test3-feature"}])
108
+ end
109
+
110
+ it "should return all, complete, everything from features" do
111
+ gr = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/simple2")
112
+
113
+ expected = [{"all" => {"keyword" => "Feature",
114
+ "name" => "Test3 Feature",
115
+ "line" => 2,
116
+ "description" => "The cat in the hat",
117
+ "tags" => [{"name" => "@top-tag", "line" => 1}],
118
+ "id" => "test3-feature",
119
+ "uri" => "fake_file.txt",
120
+ "elements" => [{"keyword" => "Scenario",
121
+ "name" => "Testing the slurping",
122
+ "line" => 6,
123
+ "description" => "",
124
+ "tags" => [{"name" => "@one", "line" => 5}],
125
+ "id" => "test3-feature;testing-the-slurping",
126
+ "type" => "scenario",
127
+ "steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 7},
128
+ {"keyword" => "Then ", "name" => "I expect something else", "line" => 8}]},
129
+ {"keyword" => "Scenario",
130
+ "name" => "Testing again",
131
+ "line" => 11,
132
+ "description" => "",
133
+ "tags" => [{"name" => "@two", "line" => 10}],
134
+ "id" => "test3-feature;testing-again",
135
+ "type" => "scenario",
136
+ "steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 12},
137
+ {"keyword" => "Then ", "name" => "I expect something else", "line" => 13}]},
138
+ {"keyword" => "Scenario",
139
+ "name" => "Testing yet again",
140
+ "line" => 16,
141
+ "description" => "",
142
+ "tags" => [{"name" => "@one", "line" => 15}],
143
+ "id" => "test3-feature;testing-yet-again",
144
+ "type" => "scenario",
145
+ "steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 17},
146
+ {"keyword" => "Then ", "name" => "I expect something else", "line" => 18}]},
147
+ {"keyword" => "Scenario",
148
+ "name" => "Testing yet again part 2",
149
+ "line" => 21,
150
+ "description" => "",
151
+ "tags" => [{"name" => "@one", "line" => 20}, {"name" => "@two", "line" => 20}],
152
+ "id" => "test3-feature;testing-yet-again-part-2",
153
+ "type" => "scenario",
154
+ "steps" => [{"keyword" => "Given ", "name" => "something happend", "line" => 22},
155
+ {"keyword" => "Then ", "name" => "I expect something else", "line" => 23}]}]}}]
156
+
157
+ result = gr.query do
158
+ select all
159
+ from features
160
+ end
161
+ expect(result).to eq(expected)
162
+
163
+ result = gr.query do
164
+ select complete
165
+ from features
166
+ end
167
+ expect(result).to eq(expected)
168
+
169
+ result = gr.query do
170
+ select everything
171
+ from features
172
+ end
173
+ expect(result).to eq(expected)
174
+ end
175
+
176
+ # it 'should return simplified tags' do
177
+ # skip
178
+ #
179
+ # gs = CQL::Repository.new("#{@feature_fixtures_directory}/scenario/tagged_features")
180
+ # result = gs.query do
181
+ # select name, basic_tag
182
+ # from features
183
+ # end
184
+ #
185
+ # expect(result).to eq([{"tags" => nil},
186
+ # {"tags" => "@one"},
187
+ # {"tags" => "@two"},
188
+ # "tags" => "@two"])
189
+ # end
190
+ end
191
+ end