Commit 5c366de

mo khan <mo@mokhan.ca>
2014-11-11 22:26:29
raise configuration error when not set up properly.
1 parent 8749cbb
Changed files (3)
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