diff --git a/lib/raven/integrations/rack.rb b/lib/raven/integrations/rack.rb index f6a411f33..68062110f 100644 --- a/lib/raven/integrations/rack.rb +++ b/lib/raven/integrations/rack.rb @@ -59,8 +59,7 @@ def call(env) raise end - error = env['rack.exception'] || env['sinatra.error'] || env['action_dispatch.exception'] - + error = env['rack.exception'] || env['sinatra.error'] Raven::Rack.capture_exception(error, env) if error response diff --git a/spec/raven/integrations/rack_spec.rb b/spec/raven/integrations/rack_spec.rb index 8f09f120e..eb3a8141b 100644 --- a/spec/raven/integrations/rack_spec.rb +++ b/spec/raven/integrations/rack_spec.rb @@ -46,22 +46,6 @@ stack.call(env) end - it 'should capture rails errors when ActionDispatch::ShowExceptions is enabled' do - exception = build_exception - env = {} - - expect(Raven::Rack).to receive(:capture_exception).with(exception, env) - - app = lambda do |e| - e['action_dispatch.exception'] = exception - [200, {}, ['okay']] - end - - stack = Raven::Rack.new(app) - - stack.call(env) - end - it 'should clear context after app is called' do Raven::Context.current.tags[:environment] = :test diff --git a/spec/raven/integrations/rails_spec.rb b/spec/raven/integrations/rails_spec.rb index 77065e1db..0de02efb3 100644 --- a/spec/raven/integrations/rails_spec.rb +++ b/spec/raven/integrations/rails_spec.rb @@ -8,17 +8,31 @@ config.dsn = 'dummy://notaserver' config.encoding = 'json' end - + Rails.env = "production" TestApp.initialize! end + after(:each) do + Raven.client.transport.events = [] + end + it "inserts middleware" do expect(TestApp.middleware).to include(Raven::Rack) end - pending "should capture exceptions" do + it "should capture exceptions in production" do get "/exception" expect(response.status).to eq(500) expect(Raven.client.transport.events.size).to eq(1) end + + it "should properly set the exception's URL" do + get "/exception" + + # TODO: dummy transport shouldn't even encode the event + event = Raven.client.transport.events.first + event = JSON.parse!(event[1]) + + expect(event['request']['url']).to eq("http://www.example.com/exception") + end end