wally 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
data/bin/wally CHANGED
@@ -7,9 +7,11 @@ if ARGV.first == "server"
7
7
  elsif ARGV[0] == "push"
8
8
  require "restclient"
9
9
  require "json"
10
+ require "wally"
10
11
  features = []
11
12
  Dir.glob(File.join("#{ARGV[2]}", "**/*.feature")).each do |feature_path|
12
- features << {:path => feature_path, :content => File.read(feature_path)}
13
+ gherkin = Wally::ParsesFeatures.new.parse(File.read(feature_path))
14
+ features << {:path => feature_path, :gherkin => gherkin}
13
15
  end
14
16
  RestClient.put "#{ARGV[1]}/features/?authentication_code=#{File.read(".wally")}", features.to_json, {:content_type => :json, :accept => :json}
15
17
  end
@@ -14,5 +14,5 @@ Feature: Counts
14
14
  Scenario: Tag Bar 2
15
15
  """
16
16
  When I visit the home page
17
- Then I should see a heading "Features (1)"
18
- And I should see a heading "Tags (5)"
17
+ Then I should see "Features (1)"
18
+ And I should see "Tags (5)"
@@ -45,8 +45,3 @@ end
45
45
  Then /^the features are ordered alphabetically$/ do
46
46
  page.body.should =~ /Elle Macpherson.*Jessica-Jane Clement.*Kate Moss.*Katie Price/m
47
47
  end
48
-
49
-
50
- Then /^I should see a heading "([^"]*)"$/ do |text|
51
- page.body.should have_content text
52
- end
@@ -13,7 +13,8 @@ Given /^I have a \.wally authentication file$/ do
13
13
  end
14
14
 
15
15
  When /^I put data to \/features with the authentication code$/ do
16
- data = [{:path => "feature-name.feature", :content => "Feature: Feature Name"}].to_json
16
+ gherkin = Wally::ParsesFeatures.new.parse("Feature: Feature Name")
17
+ data = [{:path => "feature-name.feature", :gherkin => gherkin}].to_json
17
18
  page.driver.put "/features?authentication_code=#{@authentication_code}", data
18
19
  end
19
20
 
@@ -15,6 +15,6 @@ end
15
15
  def create_feature path, content
16
16
  feature = Wally::Feature.new
17
17
  feature.path = path
18
- feature.content = content
18
+ feature.gherkin = Wally::ParsesFeatures.new.parse(content)
19
19
  feature.save
20
20
  end
data/lib/wally.rb CHANGED
@@ -8,3 +8,4 @@ require "wally/application"
8
8
  require "wally/lists_features"
9
9
  require "wally/search_features"
10
10
  require "wally/counts_tags"
11
+ require "wally/parses_features"
@@ -55,7 +55,7 @@ put '/features/?' do
55
55
  JSON.parse(request.body.read).each do |json|
56
56
  feature = Wally::Feature.new
57
57
  feature.path = json["path"]
58
- feature.content = json["content"]
58
+ feature.gherkin = json["gherkin"]
59
59
  feature.save
60
60
  end
61
61
  halt 201
data/lib/wally/feature.rb CHANGED
@@ -3,6 +3,6 @@ module Wally
3
3
  include MongoMapper::Document
4
4
 
5
5
  key :path, String
6
- key :content, String
6
+ key :gherkin, Hash
7
7
  end
8
8
  end
@@ -14,22 +14,11 @@ module Wally
14
14
  def features
15
15
  features = []
16
16
  Feature.all.each do |feature|
17
- gherkinese = parse_gherkin(feature.content)
18
- gherkinese["path"] = feature.path
19
- features << gherkinese
17
+ gherkin = feature.gherkin
18
+ gherkin["path"] = feature.path
19
+ features << gherkin
20
20
  end
21
21
  features.sort {|a,b| a["name"] <=> b["name"]}
22
22
  end
23
-
24
- private
25
-
26
- def parse_gherkin(text)
27
- io = StringIO.new
28
- formatter = Gherkin::Formatter::JSONFormatter.new(io)
29
- parser = Gherkin::Parser::Parser.new(formatter, false, 'root')
30
- parser.parse(text, nil, 0)
31
- hash = formatter.to_hash
32
- hash
33
- end
34
23
  end
35
24
  end
@@ -0,0 +1,23 @@
1
+ require 'gherkin/formatter/json_formatter'
2
+ require 'gherkin/parser/parser'
3
+
4
+ module Gherkin::Formatter
5
+ class JSONFormatter
6
+ def to_hash
7
+ @feature_hash
8
+ end
9
+ end
10
+ end
11
+
12
+ module Wally
13
+ class ParsesFeatures
14
+ def parse text
15
+ io = StringIO.new
16
+ formatter = Gherkin::Formatter::JSONFormatter.new(io)
17
+ parser = Gherkin::Parser::Parser.new(formatter, false, 'root')
18
+ parser.parse(text, nil, 0)
19
+ hash = formatter.to_hash
20
+ hash
21
+ end
22
+ end
23
+ end
data/lib/wally/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wally
2
- VERSION = "0.0.28"
2
+ VERSION = "0.0.29"
3
3
  end
@@ -1,6 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
2
  require 'fileutils'
3
- require "wally/counts_tags"
4
3
 
5
4
  module Wally
6
5
  describe CountsTags do
@@ -11,7 +10,7 @@ module Wally
11
10
  def create_feature path, content
12
11
  feature = Feature.new
13
12
  feature.path = path
14
- feature.content = content
13
+ feature.gherkin = ParsesFeatures.new.parse(content)
15
14
  feature.save
16
15
  end
17
16
 
@@ -6,19 +6,18 @@ module Wally
6
6
  Feature.delete_all
7
7
  end
8
8
 
9
- it "stores a feature" do
10
- feature = Feature.new
11
- feature.content = "Feature: Bla"
12
- feature.save
13
-
14
- Feature.all.first.content.should == "Feature: Bla"
15
- end
9
+ subject { Feature.new }
16
10
 
17
11
  it "stores a feature path" do
18
- feature = Feature.new
19
- feature.path = "hello.feature"
20
- feature.save
12
+ subject.path = "hello.feature"
13
+ subject.save
21
14
  Feature.all.first.path.should == "hello.feature"
22
15
  end
16
+
17
+ it "stores the feature content" do
18
+ subject.gherkin = {"meh" => "ble"}
19
+ subject.save
20
+ Feature.all.first.gherkin.should == {"meh" => "ble"}
21
+ end
23
22
  end
24
23
  end
@@ -10,7 +10,7 @@ module Wally
10
10
  def create_feature path, content
11
11
  feature = Feature.new
12
12
  feature.path = path
13
- feature.content = content
13
+ feature.gherkin = ParsesFeatures.new.parse(content)
14
14
  feature.save
15
15
  end
16
16
 
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+
3
+ module Wally
4
+ describe ParsesFeatures do
5
+ it "parses feature files" do
6
+ feature = "Feature: Do stuff!"
7
+ ParsesFeatures.new.parse(feature).should == {
8
+ "keyword" => "Feature",
9
+ "name" => "Do stuff!",
10
+ "line" => 1,
11
+ "description" => "",
12
+ "id" => "do-stuff!",
13
+ "uri" => nil
14
+ }
15
+ end
16
+ end
17
+ end
@@ -9,7 +9,7 @@ module Wally
9
9
  def create_feature path, content
10
10
  feature = Feature.new
11
11
  feature.path = path
12
- feature.content = content
12
+ feature.gherkin = ParsesFeatures.new.parse(content)
13
13
  feature.save
14
14
  end
15
15
 
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.28
4
+ version: 0.0.29
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70144676845360 !ruby/object:Gem::Requirement
16
+ requirement: &70100057374200 !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: *70144676845360
24
+ version_requirements: *70100057374200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sinatra
27
- requirement: &70144676844820 !ruby/object:Gem::Requirement
27
+ requirement: &70100057373740 !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: *70144676844820
35
+ version_requirements: *70100057373740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: haml
38
- requirement: &70144676844340 !ruby/object:Gem::Requirement
38
+ requirement: &70100057373320 !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: *70144676844340
46
+ version_requirements: *70100057373320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdiscount
49
- requirement: &70144676843860 !ruby/object:Gem::Requirement
49
+ requirement: &70100057372900 !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: :runtime
56
56
  prerelease: false
57
- version_requirements: *70144676843860
57
+ version_requirements: *70100057372900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: gherkin
60
- requirement: &70144676843320 !ruby/object:Gem::Requirement
60
+ requirement: &70100057372480 !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: :runtime
67
67
  prerelease: false
68
- version_requirements: *70144676843320
68
+ version_requirements: *70100057372480
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: komainu
71
- requirement: &70144676842780 !ruby/object:Gem::Requirement
71
+ requirement: &70100057372060 !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: :runtime
78
78
  prerelease: false
79
- version_requirements: *70144676842780
79
+ version_requirements: *70100057372060
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: cucumber
82
- requirement: &70144676842240 !ruby/object:Gem::Requirement
82
+ requirement: &70100057371600 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70144676842240
90
+ version_requirements: *70100057371600
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: capybara
93
- requirement: &70144676841700 !ruby/object:Gem::Requirement
93
+ requirement: &70100057371180 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70144676841700
101
+ version_requirements: *70100057371180
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rspec
104
- requirement: &70144676807080 !ruby/object:Gem::Requirement
104
+ requirement: &70100057370760 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70144676807080
112
+ version_requirements: *70100057370760
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: fakefs
115
- requirement: &70144676806660 !ruby/object:Gem::Requirement
115
+ requirement: &70100057370340 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70144676806660
123
+ version_requirements: *70100057370340
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: launchy
126
- requirement: &70144676806240 !ruby/object:Gem::Requirement
126
+ requirement: &70100057369880 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70144676806240
134
+ version_requirements: *70100057369880
135
135
  description: ''
136
136
  email:
137
137
  - andrew.vos@gmail.com
@@ -172,6 +172,7 @@ files:
172
172
  - lib/wally/counts_tags.rb
173
173
  - lib/wally/feature.rb
174
174
  - lib/wally/lists_features.rb
175
+ - lib/wally/parses_features.rb
175
176
  - lib/wally/public/bootstrap.min.css
176
177
  - lib/wally/public/skin.css
177
178
  - lib/wally/public/wally-logo.png
@@ -189,6 +190,7 @@ files:
189
190
  - spec/wally/counts_tags_spec.rb
190
191
  - spec/wally/feature_spec.rb
191
192
  - spec/wally/lists_features_spec.rb
193
+ - spec/wally/parses_features_spec.rb
192
194
  - spec/wally/search_features_spec.rb
193
195
  - wally.gemspec
194
196
  homepage: ''
@@ -234,4 +236,5 @@ test_files:
234
236
  - spec/wally/counts_tags_spec.rb
235
237
  - spec/wally/feature_spec.rb
236
238
  - spec/wally/lists_features_spec.rb
239
+ - spec/wally/parses_features_spec.rb
237
240
  - spec/wally/search_features_spec.rb