Commit 98a2788

mo <mo.khan@gmail.com>
2018-02-16 18:24:02
move error to separate file.
1 parent 232231d
lib/xml/kit/decryption.rb
@@ -1,14 +1,5 @@
 module Xml
   module Kit
-    class DecryptionError < StandardError
-      attr_reader :private_keys
-
-      def initialize(private_keys)
-        @private_keys = private_keys
-        super("Cannot decrypt document with the provided private keys")
-      end
-    end
-
     # {include:file:spec/saml/xml_decryption_spec.rb}
     class Decryption
       # The list of private keys to use to attempt to decrypt the document.
lib/xml/kit/decryption_error.rb
@@ -0,0 +1,12 @@
+module Xml
+  module Kit
+    class DecryptionError < StandardError
+      attr_reader :private_keys
+
+      def initialize(private_keys)
+        @private_keys = private_keys
+        super("Cannot decrypt document with the provided private keys")
+      end
+    end
+  end
+end
lib/xml/kit.rb
@@ -14,6 +14,7 @@ require "xml/kit/namespaces"
 require "xml/kit/certificate"
 require "xml/kit/crypto"
 require "xml/kit/decryption"
+require "xml/kit/decryption_error"
 require "xml/kit/document"
 require "xml/kit/encryption"
 require "xml/kit/fingerprint"
spec/xml/decryption_spec.rb
@@ -157,7 +157,7 @@ RSpec.describe Xml::Kit::Decryption do
 
       expect do
         subject.decrypt_node(encrypted_node)
-      end.to raise_error(/Cannot decrypt document with the provided private keys/)
+      end.to raise_error(Xml::Kit::DecryptionError)
     end
   end
 end