cql 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ require 'rspec'
2
+ require File.dirname(__FILE__) + "/../lib/" + "gherkin_repo"
3
+
4
+ describe "cql" do
5
+
6
+ describe 'filter' do
7
+ it 'should filter by a single tag' do
8
+ gs = CQL::GherkinRepository.new File.dirname(__FILE__) + "/../fixtures/features/tagged_features"
9
+
10
+ result = gs.query do
11
+ select names
12
+ from features
13
+ with tags '@one'
14
+ end
15
+
16
+ result.should == ["Test Feature", "Test3 Feature"]
17
+
18
+ result = gs.query do
19
+ select names
20
+ from features
21
+ with tags '@two'
22
+ end
23
+
24
+ result.should == ["Test2 Feature", "Test3 Feature"]
25
+ end
26
+
27
+ it 'should filter by a multiple tags' do
28
+ gs = CQL::GherkinRepository.new File.dirname(__FILE__) + "/../fixtures/features/tagged_features"
29
+
30
+ result = gs.query do
31
+ select names
32
+ from features
33
+ with tags '@one', '@two'
34
+ end
35
+
36
+ result.should == "Test3 Feature"
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,123 @@
1
+ require 'rspec'
2
+ require File.dirname(__FILE__) + "/../lib/" + "gherkin_repo"
3
+
4
+ describe "cql" do
5
+
6
+ describe "file parsing" do
7
+ it 'should find the physical files' do
8
+ gs = CQL::GherkinRepository.new File.dirname(__FILE__) + "/../fixtures/features/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
+ describe "tags" do
18
+ it "retrieve tags from a scenario" do
19
+ gs = CQL::GherkinRepository.new File.dirname(__FILE__) + "/../fixtures/features/tags2"
20
+ CQL::MapReduce.tags(gs.parsed_feature_files).sort.should == ["@five", "@four", "@one", "@two"].sort
21
+ end
22
+
23
+ it 'should filter features by tag' do
24
+ input = [{"keyword"=>"Feature", "name"=>"Simple", "line"=>1, "description"=>"", "tags"=>[{"name"=>"@two", "line"=>1}], "id"=>"simple", "uri"=>"/a/a"},
25
+ {"keyword"=>"Feature", "name"=>"Test Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test-feature"},
26
+ {"keyword"=>"Feature", "name"=>"Test2 Feature", "line"=>1, "description"=>"", "id"=>"test2-feature"},
27
+ {"keyword"=>"Feature", "name"=>"Test3 Feature", "line"=>2, "description"=>"", "tags"=>[{"name"=>"@one", "line"=>1}], "id"=>"test3-feature"}]
28
+ result = CQL::MapReduce.find_feature(input, 'tags'=>['@one'])
29
+ result.size.should == 2
30
+ result[0]['name'].should == "Test Feature"
31
+ result[1]['name'].should == "Test3 Feature"
32
+ end
33
+
34
+ end
35
+
36
+ describe 'features query' do
37
+ it 'should find all feature names' do
38
+ gs = CQL::GherkinRepository.new File.dirname(__FILE__) + "/../fixtures/features/simple"
39
+ CQL::MapReduce.overview(gs.parsed_feature_files).should eql ["Simple", "Test Feature", "Test2 Feature", "Test3 Feature"]
40
+ end
41
+
42
+ it 'should filter by a scenario by feature and then by tag' do
43
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/tags2"
44
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Not here", "@three").should == []
45
+ end
46
+
47
+ it 'should retrieve a full feature' do
48
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/simple"
49
+ result = CQL::MapReduce.find_feature(gs.parsed_feature_files, {'feature'=>"Test Feature"})
50
+ result['name'].should == "Test Feature"
51
+ result['elements'][0]['name'].should == "Testing the slurping"
52
+ result['elements'].should == [{"keyword"=>"Scenario", "name"=>"Testing the slurping", "line"=>3,
53
+ "description"=>"", "id"=>"test-feature;testing-the-slurping", "type"=>"scenario",
54
+ "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
55
+ {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}]},
56
+ {"keyword"=>"Scenario", "name"=>"Testing the slurping not to be found", "line"=>7,
57
+ "description"=>"", "id"=>"test-feature;testing-the-slurping-not-to-be-found", "type"=>"scenario",
58
+ "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>8}, {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>9}]}]
59
+ end
60
+ end
61
+
62
+ describe 'scenario query' do
63
+ it 'should get all scenarios as a list' do
64
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines"
65
+ CQL::MapReduce.find_child(gs.parsed_feature_files, {'feature'=>"Test Feature", 'what'=>'scenario'}).should == ["A Scenario"]
66
+ end
67
+
68
+ it 'should get a full scenario' do
69
+ simple_path = File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/simple"
70
+ gs = CQL::GherkinRepository.new simple_path
71
+ expected = {"keyword"=>"Scenario", "name"=>"Testing the slurping", "line"=>3,
72
+ "description"=>"", "id"=>"test-feature;testing-the-slurping", "type"=>"scenario",
73
+ "steps"=>[{"keyword"=>"Given ", "name"=>"something happend", "line"=>4},
74
+ {"keyword"=>"Then ", "name"=>"I expect something else", "line"=>5}]}
75
+ CQL::MapReduce.scenario(gs.parsed_feature_files, {'what'=>'scenario', 'feature'=>"Test Feature", 'child_name'=>"Testing the slurping"}).should == expected
76
+ end
77
+
78
+ it 'should find scenarios by a single tag' do
79
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/tags"
80
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple", true, "@one").should == ['Next', 'Another']
81
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple", true, "@two").should == ['Has a table', 'Blah']
82
+
83
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/tags2"
84
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple", true, "@one").should == ['Next', 'Another']
85
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple", true, "@two").should == ['Has a table', 'Blah']
86
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple 2", true, "@one").should == ['Next', 'Another']
87
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple 2", true, "@two").should == ['Has a table hmmm', 'Blah blah']
88
+
89
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple", true, "@three").should == []
90
+
91
+ end
92
+
93
+ it 'should find scenarios that do not have a specified tag' do
94
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/tags"
95
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple", false, "@one").should == ['Has a table', 'Blah', 'Yet Another']
96
+ #GQL::MapReduce.scenario_by_feature_wo_tag(gs.parsed_feature_files, "Simple", "@two").should == ['Has a table', 'Blah']
97
+ end
98
+
99
+ it 'should find scenarios by multiple tags' do
100
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/tags2"
101
+ CQL::MapReduce.scenario_by_feature_and_tag(gs.parsed_feature_files, "Simple 2", true, "@two", "@four").should == ['Has a table hmmm']
102
+ end
103
+
104
+ it 'should retrieve the table data' do
105
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/table"
106
+ expected = {"keyword"=>"Scenario", "name"=>"Has a table", "line"=>3, "description"=>"", "id"=>"simple;has-a-table", "type"=>"scenario",
107
+ "steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4,
108
+ "rows"=>[{"cells"=>["a", "a"], "line"=>5},
109
+ {"cells"=>["s", "a"], "line"=>6}, {"cells"=>["s", "s"], "line"=>7}]},
110
+ {"keyword"=>"Then ", "name"=>"something else", "line"=>8}]}
111
+ CQL::MapReduce.scenario(gs.parsed_feature_files, {'what'=>'scenario', 'feature'=>"Simple", 'child_name'=>"Has a table"}).should == expected
112
+ end
113
+ end
114
+
115
+ describe 'scenario outline query' do
116
+ it 'should get scenario outlines as a list' do
117
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines"
118
+ CQL::MapReduce.find_child(gs.parsed_feature_files, {'feature'=>"Test Feature", 'what'=> 'scenario'}).should == ["A Scenario"]
119
+ CQL::MapReduce.find_child(gs.parsed_feature_files, {'feature'=> "Test Feature", 'what'=> 'scenario_outline'}).should == ["An Outline"]
120
+ end
121
+ end
122
+
123
+ end
@@ -0,0 +1,53 @@
1
+ require 'rspec'
2
+ require File.dirname(__FILE__) + "/../lib/" + "gherkin_repo"
3
+
4
+ describe "cql" do
5
+ describe "select" do
6
+ it 'should find the feature file names' do
7
+ gs = CQL::GherkinRepository.new File.dirname(__FILE__) + "/../fixtures/features/simple"
8
+
9
+ result = gs.query do
10
+ select names
11
+ from features
12
+ end
13
+
14
+ result.should == ["Simple", "Test Feature", "Test2 Feature", "Test3 Feature"]
15
+ end
16
+
17
+ it 'should find the feature file names' do
18
+ gs = CQL::GherkinRepository.new File.dirname(__FILE__) + "/../fixtures/features/simple"
19
+
20
+ result = gs.query do
21
+ select uri
22
+ from features
23
+ end
24
+
25
+ result[0].should =~ /simple\.feature/
26
+ result[1].should =~ /test\.feature/
27
+ result[2].should =~ /test2\.feature/
28
+ result[3].should =~ /test_full\.feature/
29
+ end
30
+
31
+ it 'should get scenario outlines as a list' do
32
+ gs = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scen_outlines"
33
+
34
+ result = gs.query do
35
+ select names
36
+ from scenario_outlines
37
+ end
38
+
39
+ result.should == ["An Outline"]
40
+ end
41
+
42
+ it 'should get scenario as a list' do
43
+ gr = CQL::GherkinRepository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/simple2"
44
+
45
+ result = gr.query do
46
+ select names
47
+ from scenarios
48
+ end
49
+
50
+ result.should == ["Testing the slurping", "Testing again", "Testing yet again", "Testing yet again part 2"]
51
+ end
52
+ end
53
+ end
data/spec/unit_spec.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require File.dirname(__FILE__) + "/../lib/" + "gherkin_repo"
3
+
4
+ describe "cql" do
5
+
6
+ describe "tag searcher" do
7
+ it "should be able to search for tags" do
8
+ tags_given = [{"name"=>"@one", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
9
+ CQL::MapReduce.has_tags(tags_given, ["@one", "@four"]).should eql true
10
+
11
+ tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
12
+ CQL::MapReduce.has_tags(tags_given, ["@one", "@four"]).should eql false
13
+
14
+ tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
15
+ CQL::MapReduce.has_tags(tags_given, ["@four"]).should eql true
16
+
17
+ tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
18
+ CQL::MapReduce.has_tags(tags_given, ["@four", "@two", "@six", "@seven"]).should eql true
19
+ end
20
+ end
21
+
22
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cql
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jarrod Folino
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gherkin
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.8.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.8.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.4.6
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.4.6
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.7.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.7.0
78
+ description: Cucumber Query Language
79
+ email: jdfolino@gmail.com
80
+ executables: []
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - Gemfile
85
+ - README.md
86
+ - cql.gemspec
87
+ - fixtures/.gitkeep
88
+ - fixtures/features/scen_outlines/test_with_scenarios.feature
89
+ - fixtures/features/simple/simple.feature
90
+ - fixtures/features/simple/test.feature
91
+ - fixtures/features/simple/test2.feature
92
+ - fixtures/features/simple/test_full.feature
93
+ - fixtures/features/simple2/test_full.feature
94
+ - fixtures/features/table/simple.feature
95
+ - fixtures/features/tagged_features/simple.feature
96
+ - fixtures/features/tagged_features/test.feature
97
+ - fixtures/features/tagged_features/test2.feature
98
+ - fixtures/features/tagged_features/test_full.feature
99
+ - fixtures/features/tags/simple.feature
100
+ - fixtures/features/tags2/simple.feature
101
+ - fixtures/features/tags2/simple2.feature
102
+ - lib/dsl.rb
103
+ - lib/gherkin_map_reduce.rb
104
+ - lib/gherkin_repo.rb
105
+ - projectFilesBackup/.idea/workspace.xml
106
+ - spec/filter_dsl_spec.rb
107
+ - spec/map_reduce_spec.rb
108
+ - spec/select_dsl_spec.rb
109
+ - spec/unit_spec.rb
110
+ homepage:
111
+ licenses: []
112
+ post_install_message: ! '
113
+
114
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
115
+
116
+
117
+ Thank you for installing gql (Gherkin Query Language)
118
+
119
+
120
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
121
+
122
+
123
+ '
124
+ rdoc_options:
125
+ - --charset=UTF-8
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 1.8.23
143
+ signing_key:
144
+ specification_version: 3
145
+ summary: cucumber-0.0.1
146
+ test_files: []