
add ErrorHandling class, refactor spec correct the raven config class correct the raven test add a fake method for getting an exception require error_handling add new TestError class to test exceptions add correct error class to test add rescue block to raven send make method a class method and add a test Travis.config.dns add error the repos to test error remove carla method in repos add a fake error in repos delete carla method
36 lines
911 B
Ruby
36 lines
911 B
Ruby
require 'spec_helper'
|
|
require 'sentry-raven'
|
|
|
|
describe 'Exception' do
|
|
|
|
class FixRaven < Struct.new(:app)
|
|
def call(env)
|
|
requested_at = env['requested_at']
|
|
env['requested_at'] = env['requested_at'].to_s if env.key?('requested_at')
|
|
app.call(env)
|
|
rescue Exception => e
|
|
env['requested_at'] = requested_at
|
|
raise e
|
|
end
|
|
end
|
|
|
|
class TestError < StandardError
|
|
end
|
|
|
|
before do
|
|
set_app Raven::Rack.new(FixRaven.new(app))
|
|
Travis.config.sentry.dsn = "test"
|
|
Travis::Api::App.setup_monitoring
|
|
end
|
|
|
|
it 'enques error into a thread' do
|
|
error = TestError.new('Konstantin broke all the thingz!')
|
|
Travis::Api::App::Endpoint::Repos.any_instance.stubs(:service).raises(error)
|
|
Raven.expects(:send).with do |event|
|
|
event.message == "#{error.class}: #{error.message}"
|
|
end
|
|
expect { get "/repos" }.to raise_error(TestError)
|
|
sleep 0.1
|
|
end
|
|
end
|