lilypad 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,196 @@
1
+ # Logfile created on 2009-12-03 16:29:16 -0800
2
+
3
+ Processing ApplicationController#test (for 127.0.0.1 at 2009-12-03 16:29:16) [GET]
4
+
5
+ TestError (Test):
6
+ app/controllers/application_controller.rb:16:in `test'
7
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
8
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
9
+ <internal:prelude>:8:in `synchronize'
10
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/forwardable.rb:182:in `get'
11
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:79:in `block (3 levels) in <top (required)>'
12
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `instance_eval'
13
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `block in execute'
14
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
15
+ rspec (1.2.9) lib/spec/example/example_methods.rb:37:in `execute'
16
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:214:in `block in run_examples'
17
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `each'
18
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `run_examples'
19
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:103:in `run'
20
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:23:in `block in run'
21
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `each'
22
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `run'
23
+ rspec (1.2.9) lib/spec/runner/options.rb:151:in `run_examples'
24
+ rspec (1.2.9) lib/spec/runner/command_line.rb:9:in `run'
25
+ rspec (1.2.9) bin/spec:5:in `<top (required)>'
26
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `load'
27
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `<main>'
28
+
29
+ Rendered rescues/_trace (58.2ms)
30
+ Rendered rescues/_request_and_response (1.4ms)
31
+ Rendering rescues/layout (internal_server_error)
32
+
33
+
34
+ Processing ApplicationController#test (for 127.0.0.1 at 2009-12-03 16:29:17) [GET]
35
+
36
+ TestError (Test):
37
+ app/controllers/application_controller.rb:16:in `test'
38
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
39
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
40
+ <internal:prelude>:8:in `synchronize'
41
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/forwardable.rb:182:in `get'
42
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:79:in `block (3 levels) in <top (required)>'
43
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `instance_eval'
44
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `block in execute'
45
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
46
+ rspec (1.2.9) lib/spec/example/example_methods.rb:37:in `execute'
47
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:214:in `block in run_examples'
48
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `each'
49
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `run_examples'
50
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:103:in `run'
51
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:23:in `block in run'
52
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `each'
53
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `run'
54
+ rspec (1.2.9) lib/spec/runner/options.rb:151:in `run_examples'
55
+ rspec (1.2.9) lib/spec/runner/command_line.rb:9:in `run'
56
+ rspec (1.2.9) bin/spec:5:in `<top (required)>'
57
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `load'
58
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `<main>'
59
+
60
+ Rendered rescues/_trace (87.6ms)
61
+ Rendered rescues/_request_and_response (0.3ms)
62
+ Rendering rescues/layout (internal_server_error)
63
+
64
+
65
+ Processing ApplicationController#test (for 127.0.0.1 at 2009-12-03 16:29:17) [GET]
66
+
67
+ TestError (Test):
68
+ app/controllers/application_controller.rb:16:in `test'
69
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
70
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
71
+ <internal:prelude>:8:in `synchronize'
72
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/forwardable.rb:182:in `get'
73
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:83:in `block (4 levels) in <top (required)>'
74
+ rspec (1.2.9) lib/spec/matchers/raise_error.rb:21:in `call'
75
+ rspec (1.2.9) lib/spec/matchers/raise_error.rb:21:in `matches?'
76
+ rspec (1.2.9) lib/spec/expectations/handler.rb:11:in `handle_matcher'
77
+ rspec (1.2.9) lib/spec/expectations/extensions/kernel.rb:27:in `should'
78
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:83:in `block (3 levels) in <top (required)>'
79
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `instance_eval'
80
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `block in execute'
81
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
82
+ rspec (1.2.9) lib/spec/example/example_methods.rb:37:in `execute'
83
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:214:in `block in run_examples'
84
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `each'
85
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `run_examples'
86
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:103:in `run'
87
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:23:in `block in run'
88
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `each'
89
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `run'
90
+ rspec (1.2.9) lib/spec/runner/options.rb:151:in `run_examples'
91
+ rspec (1.2.9) lib/spec/runner/command_line.rb:9:in `run'
92
+ rspec (1.2.9) bin/spec:5:in `<top (required)>'
93
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `load'
94
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `<main>'
95
+
96
+ Rendered rescues/_trace (91.8ms)
97
+ Rendered rescues/_request_and_response (0.3ms)
98
+ Rendering rescues/layout (internal_server_error)
99
+
100
+
101
+ Processing ApplicationController#test (for 127.0.0.1 at 2009-12-03 16:29:17) [GET]
102
+
103
+ TestError (Test):
104
+ app/controllers/application_controller.rb:16:in `test'
105
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
106
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
107
+ <internal:prelude>:8:in `synchronize'
108
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/forwardable.rb:182:in `get'
109
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:83:in `block (4 levels) in <top (required)>'
110
+ rspec (1.2.9) lib/spec/matchers/raise_error.rb:21:in `call'
111
+ rspec (1.2.9) lib/spec/matchers/raise_error.rb:21:in `matches?'
112
+ rspec (1.2.9) lib/spec/expectations/handler.rb:11:in `handle_matcher'
113
+ rspec (1.2.9) lib/spec/expectations/extensions/kernel.rb:27:in `should'
114
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:83:in `block (3 levels) in <top (required)>'
115
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `instance_eval'
116
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `block in execute'
117
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
118
+ rspec (1.2.9) lib/spec/example/example_methods.rb:37:in `execute'
119
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:214:in `block in run_examples'
120
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `each'
121
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `run_examples'
122
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:103:in `run'
123
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:23:in `block in run'
124
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `each'
125
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `run'
126
+ rspec (1.2.9) lib/spec/runner/options.rb:151:in `run_examples'
127
+ rspec (1.2.9) lib/spec/runner/command_line.rb:9:in `run'
128
+ rspec (1.2.9) bin/spec:5:in `<top (required)>'
129
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `load'
130
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `<main>'
131
+
132
+ Rendered rescues/_trace (57.4ms)
133
+ Rendered rescues/_request_and_response (0.3ms)
134
+ Rendering rescues/layout (internal_server_error)
135
+
136
+
137
+ Processing ApplicationController#test (for 127.0.0.1 at 2009-12-03 16:29:17) [GET]
138
+
139
+ TestError (Test):
140
+ app/controllers/application_controller.rb:16:in `test'
141
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
142
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
143
+ <internal:prelude>:8:in `synchronize'
144
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/forwardable.rb:182:in `get'
145
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:94:in `block (3 levels) in <top (required)>'
146
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `instance_eval'
147
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `block in execute'
148
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
149
+ rspec (1.2.9) lib/spec/example/example_methods.rb:37:in `execute'
150
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:214:in `block in run_examples'
151
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `each'
152
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `run_examples'
153
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:103:in `run'
154
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:23:in `block in run'
155
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `each'
156
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `run'
157
+ rspec (1.2.9) lib/spec/runner/options.rb:151:in `run_examples'
158
+ rspec (1.2.9) lib/spec/runner/command_line.rb:9:in `run'
159
+ rspec (1.2.9) bin/spec:5:in `<top (required)>'
160
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `load'
161
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `<main>'
162
+
163
+ Rendered rescues/_trace (52.1ms)
164
+ Rendered rescues/_request_and_response (0.3ms)
165
+ Rendering rescues/layout (internal_server_error)
166
+
167
+
168
+ Processing ApplicationController#test (for 127.0.0.1 at 2009-12-03 16:29:17) [GET]
169
+
170
+ TestError (Test):
171
+ app/controllers/application_controller.rb:16:in `test'
172
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
173
+ /Users/winton/sites/repositories/active/lilypad/spec/fixtures/test_exception_middleware.rb:12:in `call'
174
+ <internal:prelude>:8:in `synchronize'
175
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/forwardable.rb:182:in `get'
176
+ /Users/winton/sites/repositories/active/lilypad/spec/rack/lilypad_spec.rb:94:in `block (3 levels) in <top (required)>'
177
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `instance_eval'
178
+ rspec (1.2.9) lib/spec/example/example_methods.rb:40:in `block in execute'
179
+ /Users/winton/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
180
+ rspec (1.2.9) lib/spec/example/example_methods.rb:37:in `execute'
181
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:214:in `block in run_examples'
182
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `each'
183
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:212:in `run_examples'
184
+ rspec (1.2.9) lib/spec/example/example_group_methods.rb:103:in `run'
185
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:23:in `block in run'
186
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `each'
187
+ rspec (1.2.9) lib/spec/runner/example_group_runner.rb:22:in `run'
188
+ rspec (1.2.9) lib/spec/runner/options.rb:151:in `run_examples'
189
+ rspec (1.2.9) lib/spec/runner/command_line.rb:9:in `run'
190
+ rspec (1.2.9) bin/spec:5:in `<top (required)>'
191
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `load'
192
+ /Users/winton/.rvm/gems/ruby/1.9.1/bin/spec:19:in `<main>'
193
+
194
+ Rendered rescues/_trace (85.1ms)
195
+ Rendered rescues/_request_and_response (0.3ms)
196
+ Rendering rescues/layout (internal_server_error)
@@ -1,8 +1,13 @@
1
1
  class SinatraApp < Sinatra::Base
2
2
 
3
3
  use Rack::Lilypad, 'xxx'
4
+ use TestExceptionMiddleware
4
5
 
5
- get "/pulse" do
6
+ get "/nothing" do
7
+ nil
8
+ end
9
+
10
+ get "/test" do
6
11
  raise TestError, 'Test'
7
12
  end
8
13
  end
@@ -0,0 +1,15 @@
1
+ class TestExceptionMiddleware
2
+ def initialize(app, session_key = '_session_id')
3
+ @app = app
4
+ @session_key = session_key
5
+ end
6
+
7
+ def call(env)
8
+ req = Rack::Request.new(env)
9
+ if req.params['test_exception']
10
+ raise "raising a RuntimeError to test the middleware exception"
11
+ else
12
+ @app.call(env)
13
+ end
14
+ end
15
+ end
@@ -5,9 +5,8 @@ describe Rack::Lilypad do
5
5
  include Rack::Test::Methods
6
6
 
7
7
  before(:each) do
8
- ENV['RAILS_ENV'] = ENV['RACK_ENV'] = 'production'
9
8
  @app = lambda { |env| raise TestError, 'Test' }
10
- @env = Rack::MockRequest.env_for("/pulse")
9
+ @env = Rack::MockRequest.env_for("/test")
11
10
  @http = mock(:http)
12
11
  @http.stub!(:read_timeout=)
13
12
  @http.stub!(:open_timeout=)
@@ -71,15 +70,28 @@ describe Rack::Lilypad do
71
70
  ActionController::Dispatcher.new
72
71
  end
73
72
 
73
+ it "should set ENV['RACK_ENV']" do
74
+ ENV['RACK_ENV'].should == 'production'
75
+ end
76
+
74
77
  it "should post an error to Hoptoad" do
75
78
  @http.should_receive(:post)
76
- get "/pulse" rescue nil
79
+ get "/test" rescue nil
80
+ end
81
+
82
+ it "should re-raise the exception (with ActionController::Failsafe disabled)" do
83
+ lambda { get "/test" }.should raise_error(TestError)
84
+ end
85
+
86
+ it "should catch middleware exceptions" do
87
+ @http.should_receive(:post)
88
+ get "/nothing?test_exception=1" rescue nil
77
89
  end
78
90
 
79
91
  it "should not do anything if non-production environment" do
80
92
  ENV['RACK_ENV'] = 'development'
81
93
  @http.should_not_receive(:post)
82
- get "/pulse" rescue nil
94
+ get "/test" rescue nil
83
95
  end
84
96
  end
85
97
 
@@ -89,19 +101,28 @@ describe Rack::Lilypad do
89
101
  SinatraApp.new
90
102
  end
91
103
 
104
+ before(:each) do
105
+ ENV['RACK_ENV'] = 'production'
106
+ end
107
+
92
108
  it "should post an error to Hoptoad" do
93
109
  @http.should_receive(:post)
94
- get "/pulse" rescue nil
110
+ get "/test" rescue nil
95
111
  end
96
112
 
97
113
  it "should re-raise the exception" do
98
- lambda { get "/pulse" }.should raise_error(TestError)
114
+ lambda { get "/test" }.should raise_error(TestError)
115
+ end
116
+
117
+ it "should catch middleware exceptions" do
118
+ @http.should_receive(:post)
119
+ get "/nothing?test_exception=1" rescue nil
99
120
  end
100
121
 
101
122
  it "should not do anything if non-production environment" do
102
123
  ENV['RACK_ENV'] = 'development'
103
124
  @http.should_not_receive(:post)
104
- get "/pulse" rescue nil
125
+ get "/test" rescue nil
105
126
  end
106
127
  end
107
128
  end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,10 @@ require 'nokogiri'
10
10
  require 'rack/test'
11
11
  require 'sinatra/base'
12
12
 
13
+ # Depend on rack/lilypad/rails to set ENV['RACK_ENV'] from this
14
+ ENV['RAILS_ENV'] = 'production'
15
+
16
+ require File.expand_path("#{SPEC}/fixtures/test_exception_middleware")
13
17
  require File.expand_path("#{SPEC}/fixtures/rails/config/environment")
14
18
  require File.expand_path("#{SPEC}/fixtures/sinatra")
15
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lilypad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
@@ -32,6 +32,7 @@ extra_rdoc_files:
32
32
  - README.markdown
33
33
  files:
34
34
  - gemspec.rb
35
+ - lib/rack/lilypad/rails.rb
35
36
  - lib/rack/lilypad.rb
36
37
  - MIT-LICENSE
37
38
  - Rakefile
@@ -52,7 +53,10 @@ files:
52
53
  - spec/fixtures/rails/config/locales/en.yml
53
54
  - spec/fixtures/rails/config/routes.rb
54
55
  - spec/fixtures/rails/log/development.log
56
+ - spec/fixtures/rails/log/production.log
57
+ - spec/fixtures/rails/log/staging.log
55
58
  - spec/fixtures/sinatra.rb
59
+ - spec/fixtures/test_exception_middleware.rb
56
60
  - spec/rack/lilypad_spec.rb
57
61
  - spec/spec.opts
58
62
  - spec/spec_helper.rb