From: Kevin Clark Date: Wed, 18 Jun 2008 01:04:34 +0000 (+0000) Subject: Start speccing exceptions and restore the (message) arg to super in Thrift::Applicati... X-Git-Tag: 0.2.0~610 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=95833c52506a5bf7358d046ae950d53953e7a468;p=common%2Fthrift.git Start speccing exceptions and restore the (message) arg to super in Thrift::ApplicationException git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668939 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/lib/thrift/exceptions.rb b/lib/rb/lib/thrift/exceptions.rb index f0e1b8a8..20be9c37 100644 --- a/lib/rb/lib/thrift/exceptions.rb +++ b/lib/rb/lib/thrift/exceptions.rb @@ -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 index 00000000..e460a271 --- /dev/null +++ b/lib/rb/spec/exception_spec.rb @@ -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