remove unnecessary requires, inital work on spec

This commit is contained in:
carlad 2016-07-21 17:56:41 +02:00
parent 27dbe9a75a
commit 185067265c
3 changed files with 26 additions and 8 deletions

View File

@ -1,14 +1,14 @@
require 'sentry-raven'
# require 'sentry-raven'
module Travis::API::V3
class Router
include Travis::API::V3
attr_accessor :routes, :metrics_processor
Raven.configure do |config|
config.dsn = Travis.config.sentry.dsn
end
# Raven.configure do |config|
# config.dsn = Travis.config.sentry.dsn
# end
def initialize(routes = Routes)
@routes = routes
@ -44,7 +44,7 @@ module Travis::API::V3
response
rescue Error => error
Raven.capture do
1 / 0
# 1 / 0
metrics.tick(:service)
result = Result.new(access_control, :error, error)

View File

@ -10,7 +10,6 @@ require 'gh'
require 'multi_json'
require 'pry'
require 'stackprof'
require 'sentry-raven'
require 'travis/api/app'
require 'travis/testing'

View File

@ -1,3 +1,5 @@
require 'sentry-raven'
describe Travis::API::V3::ServiceIndex, set_app: true do
let(:headers) {{ }}
let(:path) { "/v3/repo/1/enable" }
@ -6,8 +8,25 @@ describe Travis::API::V3::ServiceIndex, set_app: true do
let(:resources) { json.fetch('resources') }
it "handles wrong HTTP method with 405 status" do
response.status.should == 405
end
end
describe Travis::API::V3::Router, set_app: true do
class TestError < StandardError
end
before do
Travis.config.sentry.dsn = "test"
end
it 'Sentry captures router errors' do
error = TestError.new('Konstantin broke all the thingz!')
Travis::API::V3::Models::Repository.any_instance.stubs(:service).raises(error)
Raven.expects(:capture).with do |event|
event.message == "#{error.class}: #{error.message}"
end
expect { get "/v3/repo/1" }.to raise_error(TestError)
sleep 0.1
end
end