summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-11-11 15:26:29 -0700
committermo khan <mo@mokhan.ca>2014-11-11 15:26:29 -0700
commit5c366de651e0ec2a4708f4b61bb513273ea7457b (patch)
tree4eaaa8e06f0cf336d0c3b664cf1d9a4bc6e91b78
parent8749cbb3d78f402f2d8fcc08325773c9d7ce7549 (diff)
raise configuration error when not set up properly.
-rw-r--r--lib/urkel.rb8
-rw-r--r--lib/urkel/connection.rb2
-rw-r--r--spec/urkel_spec.rb5
3 files changed, 13 insertions, 2 deletions
diff --git a/lib/urkel.rb b/lib/urkel.rb
index 23db6ba..258e82e 100644
--- a/lib/urkel.rb
+++ b/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
diff --git a/lib/urkel/connection.rb b/lib/urkel/connection.rb
index 646a825..b7212a5 100644
--- a/lib/urkel/connection.rb
+++ b/lib/urkel/connection.rb
@@ -1,6 +1,4 @@
module Urkel
- class InvalidAPITokenError < StandardError; end
-
class Connection
API_ENDPOINT="/api/v1/failures"
diff --git a/spec/urkel_spec.rb b/spec/urkel_spec.rb
index 8e63d01..e64a1b1 100644
--- a/spec/urkel_spec.rb
+++ b/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