wally 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/features/support/env.rb +5 -5
- data/lib/wally/application.rb +14 -5
- data/lib/wally/lists_features.rb +18 -17
- data/lib/wally/search_features.rb +5 -1
- data/lib/wally/version.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- data/spec/wally/lists_features_spec.rb +5 -4
- data/spec/wally/search_features_spec.rb +11 -7
- metadata +15 -16
data/features/support/env.rb
CHANGED
@@ -8,18 +8,18 @@ require "fakefs/spec_helpers"
|
|
8
8
|
|
9
9
|
Capybara.app = Sinatra::Application
|
10
10
|
|
11
|
-
FEATURE_PATH = File.join(File.dirname(__FILE__), "../../application-features")
|
12
|
-
|
13
11
|
Before do
|
14
|
-
|
12
|
+
ARGV.clear
|
13
|
+
ARGV << "application-features"
|
14
|
+
FileUtils.mkdir_p("application-features")
|
15
15
|
end
|
16
16
|
|
17
17
|
After do
|
18
|
-
FileUtils.rm_rf(
|
18
|
+
FileUtils.rm_rf("application-features")
|
19
19
|
end
|
20
20
|
|
21
21
|
def create_feature_file(file_name, contents)
|
22
|
-
File.open(File.join(
|
22
|
+
File.open(File.join("application-features", file_name), "w") do |file|
|
23
23
|
file.write(contents)
|
24
24
|
end
|
25
25
|
end
|
data/lib/wally/application.rb
CHANGED
@@ -7,17 +7,26 @@ configure do
|
|
7
7
|
set :haml, { :ugly=>true }
|
8
8
|
end
|
9
9
|
|
10
|
+
def features_path
|
11
|
+
ARGV.first || "features"
|
12
|
+
end
|
13
|
+
|
14
|
+
def lists_features
|
15
|
+
Wally::ListsFeatures.new(features_path)
|
16
|
+
end
|
17
|
+
|
10
18
|
before do
|
11
|
-
|
19
|
+
#probably remove this if not needed
|
20
|
+
@features = lists_features.features
|
12
21
|
end
|
13
22
|
|
14
23
|
get '/?' do
|
15
|
-
@features =
|
24
|
+
@features = lists_features.features
|
16
25
|
haml :index
|
17
26
|
end
|
18
27
|
|
19
28
|
get '/features/:feature/?' do |feature|
|
20
|
-
features =
|
29
|
+
features = lists_features.features
|
21
30
|
features.each do |feature_hash|
|
22
31
|
@feature = feature_hash if feature_hash["id"] == feature
|
23
32
|
end
|
@@ -28,13 +37,13 @@ end
|
|
28
37
|
|
29
38
|
get '/search/?' do
|
30
39
|
if params[:q]
|
31
|
-
@search_results = Wally::SearchFeatures.new.find(:query => params[:q])
|
40
|
+
@search_results = Wally::SearchFeatures.new(lists_features).find(:query => params[:q])
|
32
41
|
end
|
33
42
|
haml :search
|
34
43
|
end
|
35
44
|
|
36
45
|
get '/features/:feature/scenario/:scenario/?' do |feature_id, scenario_id|
|
37
|
-
|
46
|
+
lists_features.features.each do |feature|
|
38
47
|
if feature["id"] == feature_id
|
39
48
|
feature["elements"].each do |element|
|
40
49
|
if element["type"] == "background"
|
data/lib/wally/lists_features.rb
CHANGED
@@ -11,26 +11,27 @@ end
|
|
11
11
|
|
12
12
|
module Wally
|
13
13
|
class ListsFeatures
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
features
|
14
|
+
def initialize feature_path
|
15
|
+
@feature_path = feature_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def features
|
19
|
+
features = []
|
20
|
+
Dir.glob("#{@feature_path}/*.feature").each do |path|
|
21
|
+
features << parse_gherkin(File.read(path))
|
22
22
|
end
|
23
|
+
features.sort {|a,b| a["name"] <=> b["name"]}
|
24
|
+
end
|
23
25
|
|
24
|
-
|
26
|
+
private
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
28
|
+
def parse_gherkin(text)
|
29
|
+
io = StringIO.new
|
30
|
+
formatter = Gherkin::Formatter::JSONFormatter.new(io)
|
31
|
+
parser = Gherkin::Parser::Parser.new(formatter, false, 'root')
|
32
|
+
parser.parse(text, nil, 0)
|
33
|
+
hash = formatter.to_hash
|
34
|
+
hash
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
module Wally
|
2
2
|
class SearchFeatures
|
3
|
+
def initialize lists_features
|
4
|
+
@lists_features = lists_features
|
5
|
+
end
|
6
|
+
|
3
7
|
def find(query)
|
4
8
|
results = []
|
5
|
-
|
9
|
+
@lists_features.features.each do |feature|
|
6
10
|
result = SearchResult.new(feature)
|
7
11
|
|
8
12
|
if feature["tags"]
|
data/lib/wally/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -21,10 +21,11 @@ module Wally
|
|
21
21
|
File.open("application-features/3-sample.feature", "w") do |file|
|
22
22
|
file.write "Feature: Adrian"
|
23
23
|
end
|
24
|
-
ListsFeatures.features
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
lists_features = ListsFeatures.new("application-features")
|
25
|
+
lists_features.features.size.should == 3
|
26
|
+
lists_features.features[0]["name"].should == "Adrian"
|
27
|
+
lists_features.features[1]["name"].should == "Malgor"
|
28
|
+
lists_features.features[2]["name"].should == "Zorro"
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -16,18 +16,22 @@ module Wally
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
let :lists_features do
|
20
|
+
ListsFeatures.new("application-features")
|
21
|
+
end
|
22
|
+
|
19
23
|
it "finds features containing text" do
|
20
24
|
write_feature("sample1.feature", "Feature: Bla")
|
21
25
|
write_feature("sample2.feature", "Feature: Meh")
|
22
26
|
|
23
|
-
results = SearchFeatures.new.find(:query => "Meh")
|
27
|
+
results = SearchFeatures.new(lists_features).find(:query => "Meh")
|
24
28
|
results.size.should == 1
|
25
29
|
results.first.matched_feature["name"].should == "Meh"
|
26
30
|
end
|
27
31
|
|
28
32
|
it "stores the original feature in the result" do
|
29
33
|
write_feature("sample1.feature", "Feature: Bla")
|
30
|
-
results = SearchFeatures.new.find(:query => "Bla")
|
34
|
+
results = SearchFeatures.new(lists_features).find(:query => "Bla")
|
31
35
|
results.first.feature["name"].should == "Bla"
|
32
36
|
end
|
33
37
|
|
@@ -35,7 +39,7 @@ module Wally
|
|
35
39
|
write_feature("sample1.feature", "Feature: Bla")
|
36
40
|
write_feature("sample2.feature", "Feature: Meh")
|
37
41
|
|
38
|
-
results = SearchFeatures.new.find(:query => "MEH")
|
42
|
+
results = SearchFeatures.new(lists_features).find(:query => "MEH")
|
39
43
|
results.size.should == 1
|
40
44
|
results.first.matched_feature["name"].should == "Meh"
|
41
45
|
end
|
@@ -53,13 +57,13 @@ module Wally
|
|
53
57
|
end
|
54
58
|
|
55
59
|
it "finds scenarios containing text" do
|
56
|
-
results = SearchFeatures.new.find(:query => "Matched SCENARIO")
|
60
|
+
results = SearchFeatures.new(lists_features).find(:query => "Matched SCENARIO")
|
57
61
|
results.first.matched_scenarios.size.should == 1
|
58
62
|
results.first.matched_scenarios.first["name"].should == "Matched Scenario"
|
59
63
|
end
|
60
64
|
|
61
65
|
it "finds scenario steps" do
|
62
|
-
results = SearchFeatures.new.find(:query => "I DO SOME THINGS")
|
66
|
+
results = SearchFeatures.new(lists_features).find(:query => "I DO SOME THINGS")
|
63
67
|
results.first.matched_scenarios.size.should == 1
|
64
68
|
results.first.matched_scenarios.first["name"].should == "Matched Scenario"
|
65
69
|
end
|
@@ -68,13 +72,13 @@ module Wally
|
|
68
72
|
context "feature with tags" do
|
69
73
|
it "finds features by tag" do
|
70
74
|
write_feature("example-feature.feature", "@tag_name\nFeature: Example Feature")
|
71
|
-
results = SearchFeatures.new.find(:query => "@tag_NAME")
|
75
|
+
results = SearchFeatures.new(lists_features).find(:query => "@tag_NAME")
|
72
76
|
results.first.matched_feature["name"].should == "Example Feature"
|
73
77
|
end
|
74
78
|
|
75
79
|
it "finds scenarios by tag" do
|
76
80
|
write_feature("example-feature.feature", "Feature: Example Feature\n@scenario_tag\nScenario: Example Scenario")
|
77
|
-
results = SearchFeatures.new.find(:query => "@scenario_TAG")
|
81
|
+
results = SearchFeatures.new(lists_features).find(:query => "@scenario_TAG")
|
78
82
|
results.first.matched_scenarios.first["name"].should == "Example Scenario"
|
79
83
|
end
|
80
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wally
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-22 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70228063971540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70228063971540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: haml
|
27
|
-
requirement: &
|
27
|
+
requirement: &70228063971120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70228063971120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdiscount
|
38
|
-
requirement: &
|
38
|
+
requirement: &70228063970700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70228063970700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: cucumber
|
49
|
-
requirement: &
|
49
|
+
requirement: &70228063970280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70228063970280
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: capybara
|
60
|
-
requirement: &
|
60
|
+
requirement: &70228063969860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70228063969860
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70228063969440 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70228063969440
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: fakefs
|
82
|
-
requirement: &
|
82
|
+
requirement: &70228063969020 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70228063969020
|
91
91
|
description: ''
|
92
92
|
email:
|
93
93
|
- andrew.vos@gmail.com
|
@@ -98,7 +98,6 @@ extra_rdoc_files: []
|
|
98
98
|
files:
|
99
99
|
- .gitignore
|
100
100
|
- Gemfile
|
101
|
-
- Gemfile.lock
|
102
101
|
- LICENSE
|
103
102
|
- README.md
|
104
103
|
- Rakefile
|