Start speccing exceptions and restore the (message) arg to super in Thrift::Applicati...
authorKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:04:34 +0000 (01:04 +0000)
committerKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:04:34 +0000 (01:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668939 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/lib/thrift/exceptions.rb
lib/rb/spec/exception_spec.rb [new file with mode: 0644]

index f0e1b8a..20be9c3 100644 (file)
@@ -21,7 +21,7 @@ module Thrift
     attr_reader :type
 
     def initialize(type=UNKNOWN, message=nil)
-      super
+      super(message)
       @type = type
     end
 
diff --git a/lib/rb/spec/exception_spec.rb b/lib/rb/spec/exception_spec.rb
new file mode 100644 (file)
index 0000000..e460a27
--- /dev/null
@@ -0,0 +1,23 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe Thrift::Exception do
+  it "should have an accessible message" do
+    e = Thrift::Exception.new("test message")
+    e.message.should == "test message"
+  end
+end
+
+describe Thrift::ApplicationException do
+  it "should inherit from Thrift::Exception" do
+    Thrift::ApplicationException.superclass.should == Thrift::Exception
+  end
+
+  it "should have an accessible type and message" do
+    e = Thrift::ApplicationException.new
+    e.type.should == Thrift::ApplicationException::UNKNOWN
+    e.message.should be_nil
+    e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
+    e.type.should == Thrift::ApplicationException::UNKNOWN_METHOD
+    e.message.should == "test message"
+  end
+end