You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 03:04:34 UTC

svn commit: r668939 - in /incubator/thrift/trunk/lib/rb: lib/thrift/exceptions.rb spec/exception_spec.rb

Author: kclark
Date: Tue Jun 17 18:04:34 2008
New Revision: 668939

URL: http://svn.apache.org/viewvc?rev=668939&view=rev
Log:
Start speccing exceptions and restore the (message) arg to super in Thrift::ApplicationException

Added:
    incubator/thrift/trunk/lib/rb/spec/exception_spec.rb
Modified:
    incubator/thrift/trunk/lib/rb/lib/thrift/exceptions.rb

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/exceptions.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/exceptions.rb?rev=668939&r1=668938&r2=668939&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/exceptions.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/exceptions.rb Tue Jun 17 18:04:34 2008
@@ -21,7 +21,7 @@
     attr_reader :type
 
     def initialize(type=UNKNOWN, message=nil)
-      super
+      super(message)
       @type = type
     end
 

Added: incubator/thrift/trunk/lib/rb/spec/exception_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/exception_spec.rb?rev=668939&view=auto
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/exception_spec.rb (added)
+++ incubator/thrift/trunk/lib/rb/spec/exception_spec.rb Tue Jun 17 18:04:34 2008
@@ -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