Skip to content

Commit

Permalink
Correct rack.exception behavior and add corresponding test
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Oct 3, 2012
1 parent 618b90c commit fb07481
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/raven/rack.rb
Expand Up @@ -34,7 +34,7 @@ def call(env)
end

if env['rack.exception']
evt = Event.capture_rack_exception(e, env)
evt = Event.capture_rack_exception(env['rack.exception'], env)
Raven.send(evt) if evt
end

Expand Down
22 changes: 19 additions & 3 deletions spec/raven/rack_spec.rb
Expand Up @@ -11,17 +11,33 @@

it 'should capture exceptions' do
exception = build_exception()
env = { 'key' => 'value' }
env = {}

Raven::Event.should_receive(:capture_rack_exception).with(exception, env)
Raven.should_receive(:send).with(@event)

app = lambda do |e|
raise exception
end

stack = Raven::Rack.new(app)
lambda {stack.call(env)}.should raise_error(exception)
end

it 'should capture rack.exception' do
exception = build_exception()
env = {}

Raven::Event.should_receive(:capture_rack_exception).with(exception, env)
Raven.should_receive(:send).with(@event)

lambda {stack.call(env)}.should raise_error(exception)

app = lambda do |e|
e['rack.exception'] = exception
[200, {}, ['okay']]
end

stack = Raven::Rack.new(app)

stack.call(env)
end
end

0 comments on commit fb07481

Please sign in to comment.