Commit 5c366de
Changed files (3)
lib
urkel
spec
lib/urkel/connection.rb
@@ -1,6 +1,4 @@
module Urkel
- class InvalidAPITokenError < StandardError; end
-
class Connection
API_ENDPOINT="/api/v1/failures"
lib/urkel.rb
@@ -4,6 +4,9 @@ require 'urkel/configuration'
require 'urkel/connection'
module Urkel
+ class InvalidConfigurationError < StandardError; end
+ class InvalidAPITokenError < StandardError; end
+
def self.configure
configuration = Configuration.new
yield configuration
@@ -11,6 +14,11 @@ module Urkel
end
def self.oops(error)
+ raise InvalidConfigurationError.new unless @connection
@connection.publish(error)
end
+
+ def self.reset
+ @connection = nil
+ end
end
spec/urkel_spec.rb
@@ -16,5 +16,10 @@ describe Urkel do
end
expect(Urkel.oops(error)).to be_truthy
end
+
+ it 'raises an error when not configured' do
+ Urkel.reset
+ expect(-> { Urkel.oops(error) }).to raise_error(Urkel::InvalidConfigurationError)
+ end
end
end