You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2012/09/28 03:59:05 UTC

svn commit: r1391280 [1/2] - in /thrift/trunk/lib/rb: ./ spec/

Author: jfarrell
Date: Fri Sep 28 01:59:04 2012
New Revision: 1391280

URL: http://svn.apache.org/viewvc?rev=1391280&view=rev
Log:
Thrift-1644:Upgrade RSpec to 2.11.x and refactor specs as needed
Client: rb
Patch: Nathan Beyer

Upgrading to rspec2.


Modified:
    thrift/trunk/lib/rb/Rakefile
    thrift/trunk/lib/rb/spec/base_protocol_spec.rb
    thrift/trunk/lib/rb/spec/base_transport_spec.rb
    thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb
    thrift/trunk/lib/rb/spec/binary_protocol_spec.rb
    thrift/trunk/lib/rb/spec/binary_protocol_spec_shared.rb
    thrift/trunk/lib/rb/spec/client_spec.rb
    thrift/trunk/lib/rb/spec/compact_protocol_spec.rb
    thrift/trunk/lib/rb/spec/exception_spec.rb
    thrift/trunk/lib/rb/spec/http_client_spec.rb
    thrift/trunk/lib/rb/spec/json_protocol_spec.rb
    thrift/trunk/lib/rb/spec/mongrel_http_server_spec.rb
    thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb
    thrift/trunk/lib/rb/spec/processor_spec.rb
    thrift/trunk/lib/rb/spec/serializer_spec.rb
    thrift/trunk/lib/rb/spec/server_socket_spec.rb
    thrift/trunk/lib/rb/spec/server_spec.rb
    thrift/trunk/lib/rb/spec/socket_spec.rb
    thrift/trunk/lib/rb/spec/socket_spec_shared.rb
    thrift/trunk/lib/rb/spec/spec_helper.rb
    thrift/trunk/lib/rb/spec/struct_nested_containers_spec.rb
    thrift/trunk/lib/rb/spec/struct_spec.rb
    thrift/trunk/lib/rb/spec/types_spec.rb
    thrift/trunk/lib/rb/spec/union_spec.rb
    thrift/trunk/lib/rb/spec/unix_socket_spec.rb
    thrift/trunk/lib/rb/thrift.gemspec

Modified: thrift/trunk/lib/rb/Rakefile
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/Rakefile?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/Rakefile (original)
+++ thrift/trunk/lib/rb/Rakefile Fri Sep 28 01:59:04 2012
@@ -20,21 +20,19 @@
 require 'rubygems'
 require 'rake'
 require 'rake/clean'
-require 'spec/rake/spectask'
+require 'rspec/core/rake_task'
 
 THRIFT = '../../compiler/cpp/thrift'
 
 task :default => [:gem]
 task :spec => [:'gen-rb', :build_ext, :realspec]
 
-Spec::Rake::SpecTask.new(:realspec) do |t|
-  t.spec_files = FileList['spec/**/*_spec.rb']
-  t.spec_opts = ['--color']
+RSpec::Core::RakeTask.new(:realspec) do |t|
+  t.rspec_opts = ['--color', '--format d']
 end
 
-Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
-  t.spec_files = FileList['spec/**/*_spec.rb']
-  t.spec_opts = ['--color']
+RSpec::Core::RakeTask.new(:'spec:rcov') do |t|
+  t.rspec_opts = ['--color', '--format d']
   t.rcov = true
   t.rcov_opts = ['--exclude', '^spec,/gems/']
 end

Modified: thrift/trunk/lib/rb/spec/base_protocol_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/base_protocol_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/base_protocol_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/base_protocol_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,17 +17,16 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftBaseProtocolSpec < Spec::ExampleGroup
-  include Thrift
+describe 'BaseProtocol' do
 
   before(:each) do
     @trans = mock("MockTransport")
-    @prot = BaseProtocol.new(@trans)
+    @prot = Thrift::BaseProtocol.new(@trans)
   end
 
-  describe BaseProtocol do
+  describe Thrift::BaseProtocol do
     # most of the methods are stubs, so we can ignore them
 
     it "should make trans accessible" do
@@ -51,16 +50,16 @@ class ThriftBaseProtocolSpec < Spec::Exa
       @prot.should_receive(:write_string).with('string').ordered
       struct = mock('Struct')
       struct.should_receive(:write).with(@prot).ordered
-      @prot.write_type(Types::BOOL, 'bool')
-      @prot.write_type(Types::BYTE, 'byte')
-      @prot.write_type(Types::DOUBLE, 'double')
-      @prot.write_type(Types::I16, 'i16')
-      @prot.write_type(Types::I32, 'i32')
-      @prot.write_type(Types::I64, 'i64')
-      @prot.write_type(Types::STRING, 'string')
-      @prot.write_type(Types::STRUCT, struct)
+      @prot.write_type(Thrift::Types::BOOL, 'bool')
+      @prot.write_type(Thrift::Types::BYTE, 'byte')
+      @prot.write_type(Thrift::Types::DOUBLE, 'double')
+      @prot.write_type(Thrift::Types::I16, 'i16')
+      @prot.write_type(Thrift::Types::I32, 'i32')
+      @prot.write_type(Thrift::Types::I64, 'i64')
+      @prot.write_type(Thrift::Types::STRING, 'string')
+      @prot.write_type(Thrift::Types::STRUCT, struct)
       # all other types are not implemented
-      [Types::STOP, Types::VOID, Types::MAP, Types::SET, Types::LIST].each do |type|
+      [Thrift::Types::STOP, Thrift::Types::VOID, Thrift::Types::MAP, Thrift::Types::SET, Thrift::Types::LIST].each do |type|
         lambda { @prot.write_type(type, type.to_s) }.should raise_error(NotImplementedError)
       end
     end
@@ -73,15 +72,15 @@ class ThriftBaseProtocolSpec < Spec::Exa
       @prot.should_receive(:read_i64).ordered
       @prot.should_receive(:read_double).ordered
       @prot.should_receive(:read_string).ordered
-      @prot.read_type(Types::BOOL)
-      @prot.read_type(Types::BYTE)
-      @prot.read_type(Types::I16)
-      @prot.read_type(Types::I32)
-      @prot.read_type(Types::I64)
-      @prot.read_type(Types::DOUBLE)
-      @prot.read_type(Types::STRING)
+      @prot.read_type(Thrift::Types::BOOL)
+      @prot.read_type(Thrift::Types::BYTE)
+      @prot.read_type(Thrift::Types::I16)
+      @prot.read_type(Thrift::Types::I32)
+      @prot.read_type(Thrift::Types::I64)
+      @prot.read_type(Thrift::Types::DOUBLE)
+      @prot.read_type(Thrift::Types::STRING)
       # all other types are not implemented
-      [Types::STOP, Types::VOID, Types::MAP, Types::SET, Types::LIST].each do |type|
+      [Thrift::Types::STOP, Thrift::Types::VOID, Thrift::Types::MAP, Thrift::Types::SET, Thrift::Types::LIST].each do |type|
         lambda { @prot.read_type(type) }.should raise_error(NotImplementedError)
       end
     end
@@ -94,67 +93,67 @@ class ThriftBaseProtocolSpec < Spec::Exa
       @prot.should_receive(:read_i64).ordered
       @prot.should_receive(:read_double).ordered
       @prot.should_receive(:read_string).ordered
-      @prot.skip(Types::BOOL)
-      @prot.skip(Types::BYTE)
-      @prot.skip(Types::I16)
-      @prot.skip(Types::I32)
-      @prot.skip(Types::I64)
-      @prot.skip(Types::DOUBLE)
-      @prot.skip(Types::STRING)
-      @prot.skip(Types::STOP) # should do absolutely nothing
+      @prot.skip(Thrift::Types::BOOL)
+      @prot.skip(Thrift::Types::BYTE)
+      @prot.skip(Thrift::Types::I16)
+      @prot.skip(Thrift::Types::I32)
+      @prot.skip(Thrift::Types::I64)
+      @prot.skip(Thrift::Types::DOUBLE)
+      @prot.skip(Thrift::Types::STRING)
+      @prot.skip(Thrift::Types::STOP) # should do absolutely nothing
     end
 
     it "should skip structs" do
       real_skip = @prot.method(:skip)
       @prot.should_receive(:read_struct_begin).ordered
       @prot.should_receive(:read_field_begin).exactly(4).times.and_return(
-        ['field 1', Types::STRING, 1],
-        ['field 2', Types::I32, 2],
-        ['field 3', Types::MAP, 3],
-        [nil, Types::STOP, 0]
+        ['field 1', Thrift::Types::STRING, 1],
+        ['field 2', Thrift::Types::I32, 2],
+        ['field 3', Thrift::Types::MAP, 3],
+        [nil, Thrift::Types::STOP, 0]
       )
       @prot.should_receive(:read_field_end).exactly(3).times
       @prot.should_receive(:read_string).exactly(3).times
       @prot.should_receive(:read_i32).ordered
-      @prot.should_receive(:read_map_begin).ordered.and_return([Types::STRING, Types::STRING, 1])
+      @prot.should_receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRING, 1])
       # @prot.should_receive(:read_string).exactly(2).times
       @prot.should_receive(:read_map_end).ordered
       @prot.should_receive(:read_struct_end).ordered
-      real_skip.call(Types::STRUCT)
+      real_skip.call(Thrift::Types::STRUCT)
     end
 
     it "should skip maps" do
       real_skip = @prot.method(:skip)
-      @prot.should_receive(:read_map_begin).ordered.and_return([Types::STRING, Types::STRUCT, 1])
+      @prot.should_receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRUCT, 1])
       @prot.should_receive(:read_string).ordered
       @prot.should_receive(:read_struct_begin).ordered.and_return(["some_struct"])
-      @prot.should_receive(:read_field_begin).ordered.and_return([nil, Types::STOP, nil]);
+      @prot.should_receive(:read_field_begin).ordered.and_return([nil, Thrift::Types::STOP, nil]);
       @prot.should_receive(:read_struct_end).ordered
       @prot.should_receive(:read_map_end).ordered
-      real_skip.call(Types::MAP)
+      real_skip.call(Thrift::Types::MAP)
     end
 
     it "should skip sets" do
       real_skip = @prot.method(:skip)
-      @prot.should_receive(:read_set_begin).ordered.and_return([Types::I64, 9])
+      @prot.should_receive(:read_set_begin).ordered.and_return([Thrift::Types::I64, 9])
       @prot.should_receive(:read_i64).ordered.exactly(9).times
       @prot.should_receive(:read_set_end)
-      real_skip.call(Types::SET)
+      real_skip.call(Thrift::Types::SET)
     end
 
     it "should skip lists" do
       real_skip = @prot.method(:skip)
-      @prot.should_receive(:read_list_begin).ordered.and_return([Types::DOUBLE, 11])
+      @prot.should_receive(:read_list_begin).ordered.and_return([Thrift::Types::DOUBLE, 11])
       @prot.should_receive(:read_double).ordered.exactly(11).times
       @prot.should_receive(:read_list_end)
-      real_skip.call(Types::LIST)
+      real_skip.call(Thrift::Types::LIST)
     end
   end
 
-  describe BaseProtocolFactory do
+  describe Thrift::BaseProtocolFactory do
     it "should raise NotImplementedError" do
       # returning nil since Protocol is just an abstract class
-      lambda {BaseProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
+      lambda {Thrift::BaseProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
     end
   end
 end

Modified: thrift/trunk/lib/rb/spec/base_transport_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/base_transport_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/base_transport_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/base_transport_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,22 +17,21 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftBaseTransportSpec < Spec::ExampleGroup
-  include Thrift
+describe 'BaseTransport' do
 
-  describe TransportException do
+  describe Thrift::TransportException do
     it "should make type accessible" do
-      exc = TransportException.new(TransportException::ALREADY_OPEN, "msg")
-      exc.type.should == TransportException::ALREADY_OPEN
+      exc = Thrift::TransportException.new(Thrift::TransportException::ALREADY_OPEN, "msg")
+      exc.type.should == Thrift::TransportException::ALREADY_OPEN
       exc.message.should == "msg"
     end
   end
 
-  describe BaseTransport do
+  describe Thrift::BaseTransport do
     it "should read the specified size" do
-      transport = BaseTransport.new
+      transport = Thrift::BaseTransport.new
       transport.should_receive(:read).with(40).ordered.and_return("10 letters")
       transport.should_receive(:read).with(30).ordered.and_return("fifteen letters")
       transport.should_receive(:read).with(15).ordered.and_return("more characters")
@@ -42,47 +41,47 @@ class ThriftBaseTransportSpec < Spec::Ex
     it "should stub out the rest of the methods" do
       # can't test for stubbiness, so just make sure they're defined
       [:open?, :open, :close, :read, :write, :flush].each do |sym|
-        BaseTransport.method_defined?(sym).should be_true
+        Thrift::BaseTransport.method_defined?(sym).should be_true
       end
     end
 
     it "should alias << to write" do
-      BaseTransport.instance_method(:<<).should == BaseTransport.instance_method(:write)
+      Thrift::BaseTransport.instance_method(:<<).should == Thrift::BaseTransport.instance_method(:write)
     end
   end
 
-  describe BaseServerTransport do
+  describe Thrift::BaseServerTransport do
     it "should stub out its methods" do
       [:listen, :accept, :close].each do |sym|
-        BaseServerTransport.method_defined?(sym).should be_true
+        Thrift::BaseServerTransport.method_defined?(sym).should be_true
       end
     end
   end
 
-  describe BaseTransportFactory do
+  describe Thrift::BaseTransportFactory do
     it "should return the transport it's given" do
       transport = mock("Transport")
-      BaseTransportFactory.new.get_transport(transport).should eql(transport)
+      Thrift::BaseTransportFactory.new.get_transport(transport).should eql(transport)
     end
   end
 
-  describe BufferedTransport do
+  describe Thrift::BufferedTransport do
     it "should pass through everything but write/flush/read" do
       trans = mock("Transport")
       trans.should_receive(:open?).ordered.and_return("+ open?")
       trans.should_receive(:open).ordered.and_return("+ open")
       trans.should_receive(:flush).ordered # from the close
       trans.should_receive(:close).ordered.and_return("+ close")
-      btrans = BufferedTransport.new(trans)
+      btrans = Thrift::BufferedTransport.new(trans)
       btrans.open?.should == "+ open?"
       btrans.open.should == "+ open"
       btrans.close.should == "+ close"
     end
-    
-    it "should buffer reads in chunks of #{BufferedTransport::DEFAULT_BUFFER}" do
+
+    it "should buffer reads in chunks of #{Thrift::BufferedTransport::DEFAULT_BUFFER}" do
       trans = mock("Transport")
-      trans.should_receive(:read).with(BufferedTransport::DEFAULT_BUFFER).and_return("lorum ipsum dolor emet")
-      btrans = BufferedTransport.new(trans)
+      trans.should_receive(:read).with(Thrift::BufferedTransport::DEFAULT_BUFFER).and_return("lorum ipsum dolor emet")
+      btrans = Thrift::BufferedTransport.new(trans)
       btrans.read(6).should == "lorum "
       btrans.read(6).should == "ipsum "
       btrans.read(6).should == "dolor "
@@ -91,7 +90,7 @@ class ThriftBaseTransportSpec < Spec::Ex
 
     it "should buffer writes and send them on flush" do
       trans = mock("Transport")
-      btrans = BufferedTransport.new(trans)
+      btrans = Thrift::BufferedTransport.new(trans)
       btrans.write("one/")
       btrans.write("two/")
       btrans.write("three/")
@@ -102,7 +101,7 @@ class ThriftBaseTransportSpec < Spec::Ex
 
     it "should only send buffered data once" do
       trans = mock("Transport")
-      btrans = BufferedTransport.new(trans)
+      btrans = Thrift::BufferedTransport.new(trans)
       btrans.write("one/")
       btrans.write("two/")
       btrans.write("three/")
@@ -112,39 +111,39 @@ class ThriftBaseTransportSpec < Spec::Ex
       # Nothing to flush with no data
       btrans.flush
     end
-    
+
     it "should flush on close" do
       trans = mock("Transport")
       trans.should_receive(:close)
-      btrans = BufferedTransport.new(trans)
+      btrans = Thrift::BufferedTransport.new(trans)
       btrans.should_receive(:flush)
       btrans.close
     end
-    
+
     it "should not write to socket if there's no data" do
       trans = mock("Transport")
       trans.should_receive(:flush)
-      btrans = BufferedTransport.new(trans)
+      btrans = Thrift::BufferedTransport.new(trans)
       btrans.flush
     end
   end
 
-  describe BufferedTransportFactory do
+  describe Thrift::BufferedTransportFactory do
     it "should wrap the given transport in a BufferedTransport" do
       trans = mock("Transport")
       btrans = mock("BufferedTransport")
-      BufferedTransport.should_receive(:new).with(trans).and_return(btrans)
-      BufferedTransportFactory.new.get_transport(trans).should == btrans
+      Thrift::BufferedTransport.should_receive(:new).with(trans).and_return(btrans)
+      Thrift::BufferedTransportFactory.new.get_transport(trans).should == btrans
     end
   end
 
-  describe FramedTransport do
+  describe Thrift::FramedTransport do
     before(:each) do
       @trans = mock("Transport")
     end
 
     it "should pass through open?/open/close" do
-      ftrans = FramedTransport.new(@trans)
+      ftrans = Thrift::FramedTransport.new(@trans)
       @trans.should_receive(:open?).ordered.and_return("+ open?")
       @trans.should_receive(:open).ordered.and_return("+ open")
       @trans.should_receive(:close).ordered.and_return("+ close")
@@ -154,13 +153,13 @@ class ThriftBaseTransportSpec < Spec::Ex
     end
 
     it "should pass through read when read is turned off" do
-      ftrans = FramedTransport.new(@trans, false, true)
+      ftrans = Thrift::FramedTransport.new(@trans, false, true)
       @trans.should_receive(:read).with(17).ordered.and_return("+ read")
       ftrans.read(17).should == "+ read"
     end
 
     it "should pass through write/flush when write is turned off" do
-      ftrans = FramedTransport.new(@trans, true, false)
+      ftrans = Thrift::FramedTransport.new(@trans, true, false)
       @trans.should_receive(:write).with("foo").ordered.and_return("+ write")
       @trans.should_receive(:flush).ordered.and_return("+ flush")
       ftrans.write("foo").should == "+ write"
@@ -171,21 +170,21 @@ class ThriftBaseTransportSpec < Spec::Ex
       frame = "this is a frame"
       @trans.should_receive(:read_all).with(4).and_return("\000\000\000\017")
       @trans.should_receive(:read_all).with(frame.length).and_return(frame)
-      FramedTransport.new(@trans).read(frame.length + 10).should == frame
+      Thrift::FramedTransport.new(@trans).read(frame.length + 10).should == frame
     end
 
     it "should return slices of the frame when asked for < the frame's length" do
       frame = "this is a frame"
       @trans.should_receive(:read_all).with(4).and_return("\000\000\000\017")
       @trans.should_receive(:read_all).with(frame.length).and_return(frame)
-      ftrans = FramedTransport.new(@trans)
+      ftrans = Thrift::FramedTransport.new(@trans)
       ftrans.read(4).should == "this"
       ftrans.read(4).should == " is "
       ftrans.read(16).should == "a frame"
     end
 
     it "should return nothing if asked for <= 0" do
-      FramedTransport.new(@trans).read(-2).should == ""
+      Thrift::FramedTransport.new(@trans).read(-2).should == ""
     end
 
     it "should pull a new frame when the first is exhausted" do
@@ -194,7 +193,7 @@ class ThriftBaseTransportSpec < Spec::Ex
       @trans.should_receive(:read_all).with(4).and_return("\000\000\000\017", "\000\000\000\021")
       @trans.should_receive(:read_all).with(frame.length).and_return(frame)
       @trans.should_receive(:read_all).with(frame2.length).and_return(frame2)
-      ftrans = FramedTransport.new(@trans)
+      ftrans = Thrift::FramedTransport.new(@trans)
       ftrans.read(4).should == "this"
       ftrans.read(8).should == " is a fr"
       ftrans.read(6).should == "ame"
@@ -203,7 +202,7 @@ class ThriftBaseTransportSpec < Spec::Ex
     end
 
     it "should buffer writes" do
-      ftrans = FramedTransport.new(@trans)
+      ftrans = Thrift::FramedTransport.new(@trans)
       @trans.should_not_receive(:write)
       ftrans.write("foo")
       ftrans.write("bar")
@@ -211,7 +210,7 @@ class ThriftBaseTransportSpec < Spec::Ex
     end
 
     it "should write slices of the buffer" do
-      ftrans = FramedTransport.new(@trans)
+      ftrans = Thrift::FramedTransport.new(@trans)
       ftrans.write("foobar", 3)
       ftrans.write("barfoo", 1)
       @trans.stub!(:flush)
@@ -220,7 +219,7 @@ class ThriftBaseTransportSpec < Spec::Ex
     end
 
     it "should flush frames with a 4-byte header" do
-      ftrans = FramedTransport.new(@trans)
+      ftrans = Thrift::FramedTransport.new(@trans)
       @trans.should_receive(:write).with("\000\000\000\035one/two/three/this is a frame").ordered
       @trans.should_receive(:flush).ordered
       ftrans.write("one/")
@@ -231,7 +230,7 @@ class ThriftBaseTransportSpec < Spec::Ex
     end
 
     it "should not flush the same buffered data twice" do
-      ftrans = FramedTransport.new(@trans)
+      ftrans = Thrift::FramedTransport.new(@trans)
       @trans.should_receive(:write).with("\000\000\000\007foo/bar")
       @trans.stub!(:flush)
       ftrans.write("foo")
@@ -242,22 +241,22 @@ class ThriftBaseTransportSpec < Spec::Ex
     end
   end
 
-  describe FramedTransportFactory do
+  describe Thrift::FramedTransportFactory do
     it "should wrap the given transport in a FramedTransport" do
       trans = mock("Transport")
-      FramedTransport.should_receive(:new).with(trans)
-      FramedTransportFactory.new.get_transport(trans)
+      Thrift::FramedTransport.should_receive(:new).with(trans)
+      Thrift::FramedTransportFactory.new.get_transport(trans)
     end
   end
 
-  describe MemoryBufferTransport do
+  describe Thrift::MemoryBufferTransport do
     before(:each) do
-      @buffer = MemoryBufferTransport.new
+      @buffer = Thrift::MemoryBufferTransport.new
     end
 
     it "should accept a buffer on input and use it directly" do
       s = "this is a test"
-      @buffer = MemoryBufferTransport.new(s)
+      @buffer = Thrift::MemoryBufferTransport.new(s)
       @buffer.read(4).should == "this"
       s.slice!(-4..-1)
       @buffer.read(@buffer.available).should == " is a "
@@ -307,7 +306,7 @@ class ThriftBaseTransportSpec < Spec::Ex
       @buffer.write " bar"
       @buffer.read(@buffer.available).should == "foo bar"
     end
-    
+
     it "should throw an EOFError when there isn't enough data in the buffer" do
       @buffer.reset_buffer("")
       lambda{@buffer.read(1)}.should raise_error(EOFError)
@@ -317,11 +316,11 @@ class ThriftBaseTransportSpec < Spec::Ex
     end
   end
 
-  describe IOStreamTransport do
+  describe Thrift::IOStreamTransport do
     before(:each) do
       @input = mock("Input", :closed? => false)
       @output = mock("Output", :closed? => false)
-      @trans = IOStreamTransport.new(@input, @output)
+      @trans = Thrift::IOStreamTransport.new(@input, @output)
     end
 
     it "should be open as long as both input or output are open" do

Modified: thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,27 +17,23 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 require File.expand_path("#{File.dirname(__FILE__)}/binary_protocol_spec_shared")
 
 if defined? Thrift::BinaryProtocolAccelerated
 
-  class ThriftBinaryProtocolAcceleratedSpec < Spec::ExampleGroup
-    include Thrift
+  describe 'BinaryProtocolAccelerated' do
+    # since BinaryProtocolAccelerated should be directly equivalent to
+    # BinaryProtocol, we don't need any custom specs!
+    it_should_behave_like 'a binary protocol'
 
-    describe Thrift::BinaryProtocolAccelerated do
-      # since BinaryProtocolAccelerated should be directly equivalent to 
-      # BinaryProtocol, we don't need any custom specs!
-      it_should_behave_like 'a binary protocol'
-
-      def protocol_class
-        BinaryProtocolAccelerated
-      end
+    def protocol_class
+      Thrift::BinaryProtocolAccelerated
     end
 
-    describe BinaryProtocolAcceleratedFactory do
+    describe Thrift::BinaryProtocolAcceleratedFactory do
       it "should create a BinaryProtocolAccelerated" do
-        BinaryProtocolAcceleratedFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(BinaryProtocolAccelerated)
+        Thrift::BinaryProtocolAcceleratedFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocolAccelerated)
       end
     end
   end

Modified: thrift/trunk/lib/rb/spec/binary_protocol_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/binary_protocol_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/binary_protocol_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/binary_protocol_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,17 +17,22 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 require File.expand_path("#{File.dirname(__FILE__)}/binary_protocol_spec_shared")
 
-class ThriftBinaryProtocolSpec < Spec::ExampleGroup
-  include Thrift
+describe 'BinaryProtocol' do
 
-  describe BinaryProtocol do
-    it_should_behave_like 'a binary protocol'
+  it_should_behave_like 'a binary protocol'
 
-    def protocol_class
-      BinaryProtocol
+  def protocol_class
+    Thrift::BinaryProtocol
+  end
+
+  describe Thrift::BinaryProtocol do
+
+    before(:each) do
+      @trans = Thrift::MemoryBufferTransport.new
+      @prot = protocol_class.new(@trans)
     end
 
     it "should read a message header" do
@@ -47,15 +52,15 @@ class ThriftBinaryProtocolSpec < Spec::E
     it "should raise an exception if the message header does not exist and strict_read is enabled" do
       @prot.should_receive(:read_i32).and_return(42)
       @prot.should_receive(:strict_read).and_return(true)
-      lambda { @prot.read_message_begin }.should raise_error(Thrift::ProtocolException, 'No version identifier, old protocol client?') do |e|        
+      lambda { @prot.read_message_begin }.should raise_error(Thrift::ProtocolException, 'No version identifier, old protocol client?') do |e|
         e.type == Thrift::ProtocolException::BAD_VERSION
       end
     end
   end
 
-  describe BinaryProtocolFactory do
+  describe Thrift::BinaryProtocolFactory do
     it "should create a BinaryProtocol" do
-      BinaryProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(BinaryProtocol)
+      Thrift::BinaryProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocol)
     end
   end
 end

Modified: thrift/trunk/lib/rb/spec/binary_protocol_spec_shared.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/binary_protocol_spec_shared.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/binary_protocol_spec_shared.rb (original)
+++ thrift/trunk/lib/rb/spec/binary_protocol_spec_shared.rb Fri Sep 28 01:59:04 2012
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
 shared_examples_for 'a binary protocol' do
   before(:each) do

Modified: thrift/trunk/lib/rb/spec/client_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/client_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/client_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/client_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,10 +17,9 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftClientSpec < Spec::ExampleGroup
-  include Thrift
+describe 'Client' do
 
   class ClientSpec
     include Thrift::Client
@@ -31,14 +30,14 @@ class ThriftClientSpec < Spec::ExampleGr
     @client = ClientSpec.new(@prot)
   end
 
-  describe Client do
+  describe Thrift::Client do
     it "should re-use iprot for oprot if not otherwise specified" do
       @client.instance_variable_get(:'@iprot').should eql(@prot)
       @client.instance_variable_get(:'@oprot').should eql(@prot)
     end
 
     it "should send a test message" do
-      @prot.should_receive(:write_message_begin).with('testMessage', MessageTypes::CALL, 0)
+      @prot.should_receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 0)
       mock_args = mock('#<TestMessage_args:mock>')
       mock_args.should_receive(:foo=).with('foo')
       mock_args.should_receive(:bar=).with(42)
@@ -55,19 +54,19 @@ class ThriftClientSpec < Spec::ExampleGr
 
     it "should increment the sequence id when sending messages" do
       pending "it seems sequence ids are completely ignored right now" do
-        @prot.should_receive(:write_message_begin).with('testMessage',  MessageTypes::CALL, 0).ordered
-        @prot.should_receive(:write_message_begin).with('testMessage2', MessageTypes::CALL, 1).ordered
-        @prot.should_receive(:write_message_begin).with('testMessage3', MessageTypes::CALL, 2).ordered
+        @prot.should_receive(:write_message_begin).with('testMessage',  Thrift::MessageTypes::CALL, 0).ordered
+        @prot.should_receive(:write_message_begin).with('testMessage2', Thrift::MessageTypes::CALL, 1).ordered
+        @prot.should_receive(:write_message_begin).with('testMessage3', Thrift::MessageTypes::CALL, 2).ordered
         @prot.stub!(:write_message_end)
         @prot.stub!(:trans).and_return mock("trans").as_null_object
         @client.send_message('testMessage', mock("args class").as_null_object)
         @client.send_message('testMessage2', mock("args class").as_null_object)
-        @client.send_message('testMessage3', mock("args class").as_null_object)        
+        @client.send_message('testMessage3', mock("args class").as_null_object)
       end
     end
 
     it "should receive a test message" do
-      @prot.should_receive(:read_message_begin).and_return [nil, MessageTypes::CALL, 0]
+      @prot.should_receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::CALL, 0]
       @prot.should_receive(:read_message_end)
       mock_klass = mock("#<MockClass:mock>")
       mock_klass.should_receive(:read).with(@prot)
@@ -75,9 +74,9 @@ class ThriftClientSpec < Spec::ExampleGr
     end
 
     it "should handle received exceptions" do
-      @prot.should_receive(:read_message_begin).and_return [nil, MessageTypes::EXCEPTION, 0]
+      @prot.should_receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::EXCEPTION, 0]
       @prot.should_receive(:read_message_end)
-      ApplicationException.should_receive(:new).and_return do
+      Thrift::ApplicationException.should_receive(:new).and_return do
         StandardError.new.tee do |mock_exc|
           mock_exc.should_receive(:read).with(@prot)
         end

Modified: thrift/trunk/lib/rb/spec/compact_protocol_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/compact_protocol_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/compact_protocol_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/compact_protocol_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
 describe Thrift::CompactProtocol do
   TESTS = {

Modified: thrift/trunk/lib/rb/spec/exception_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/exception_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/exception_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/exception_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,29 +17,28 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftExceptionSpec < Spec::ExampleGroup
-  include Thrift
+describe 'Exception' do
 
-  describe Exception do
+  describe Thrift::Exception do
     it "should have an accessible message" do
-      e = Exception.new("test message")
+      e = Thrift::Exception.new("test message")
       e.message.should == "test message"
     end
   end
 
-  describe ApplicationException do
+  describe Thrift::ApplicationException do
     it "should inherit from Thrift::Exception" do
-      ApplicationException.superclass.should == Exception
+      Thrift::ApplicationException.superclass.should == Thrift::Exception
     end
 
     it "should have an accessible type and message" do
-      e = ApplicationException.new
-      e.type.should == ApplicationException::UNKNOWN
+      e = Thrift::ApplicationException.new
+      e.type.should == Thrift::ApplicationException::UNKNOWN
       e.message.should be_nil
-      e = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, "test message")
-      e.type.should == ApplicationException::UNKNOWN_METHOD
+      e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
+      e.type.should == Thrift::ApplicationException::UNKNOWN_METHOD
       e.message.should == "test message"
     end
 
@@ -47,79 +46,79 @@ class ThriftExceptionSpec < Spec::Exampl
       prot = mock("MockProtocol")
       prot.should_receive(:read_struct_begin).ordered
       prot.should_receive(:read_field_begin).exactly(3).times.and_return(
-        ["message", Types::STRING, 1],
-        ["type", Types::I32, 2],
-        [nil, Types::STOP, 0]
+        ["message", Thrift::Types::STRING, 1],
+        ["type", Thrift::Types::I32, 2],
+        [nil, Thrift::Types::STOP, 0]
       )
       prot.should_receive(:read_string).ordered.and_return "test message"
-      prot.should_receive(:read_i32).ordered.and_return ApplicationException::BAD_SEQUENCE_ID
+      prot.should_receive(:read_i32).ordered.and_return Thrift::ApplicationException::BAD_SEQUENCE_ID
       prot.should_receive(:read_field_end).exactly(2).times
       prot.should_receive(:read_struct_end).ordered
 
-      e = ApplicationException.new
+      e = Thrift::ApplicationException.new
       e.read(prot)
       e.message.should == "test message"
-      e.type.should == ApplicationException::BAD_SEQUENCE_ID
+      e.type.should == Thrift::ApplicationException::BAD_SEQUENCE_ID
     end
 
     it "should skip bad fields when reading a struct" do
       prot = mock("MockProtocol")
       prot.should_receive(:read_struct_begin).ordered
       prot.should_receive(:read_field_begin).exactly(5).times.and_return(
-        ["type", Types::I32, 2],
-        ["type", Types::STRING, 2],
-        ["message", Types::MAP, 1],
-        ["message", Types::STRING, 3],
-        [nil, Types::STOP, 0]
+        ["type", Thrift::Types::I32, 2],
+        ["type", Thrift::Types::STRING, 2],
+        ["message", Thrift::Types::MAP, 1],
+        ["message", Thrift::Types::STRING, 3],
+        [nil, Thrift::Types::STOP, 0]
       )
-      prot.should_receive(:read_i32).and_return ApplicationException::INVALID_MESSAGE_TYPE
-      prot.should_receive(:skip).with(Types::STRING).twice
-      prot.should_receive(:skip).with(Types::MAP)
+      prot.should_receive(:read_i32).and_return Thrift::ApplicationException::INVALID_MESSAGE_TYPE
+      prot.should_receive(:skip).with(Thrift::Types::STRING).twice
+      prot.should_receive(:skip).with(Thrift::Types::MAP)
       prot.should_receive(:read_field_end).exactly(4).times
       prot.should_receive(:read_struct_end).ordered
 
-      e = ApplicationException.new
+      e = Thrift::ApplicationException.new
       e.read(prot)
       e.message.should be_nil
-      e.type.should == ApplicationException::INVALID_MESSAGE_TYPE
+      e.type.should == Thrift::ApplicationException::INVALID_MESSAGE_TYPE
     end
 
     it "should write a Thrift::ApplicationException struct to the oprot" do
       prot = mock("MockProtocol")
       prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
-      prot.should_receive(:write_field_begin).with("message", Types::STRING, 1).ordered
+      prot.should_receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
       prot.should_receive(:write_string).with("test message").ordered
-      prot.should_receive(:write_field_begin).with("type", Types::I32, 2).ordered
-      prot.should_receive(:write_i32).with(ApplicationException::UNKNOWN_METHOD).ordered
+      prot.should_receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
+      prot.should_receive(:write_i32).with(Thrift::ApplicationException::UNKNOWN_METHOD).ordered
       prot.should_receive(:write_field_end).twice
       prot.should_receive(:write_field_stop).ordered
       prot.should_receive(:write_struct_end).ordered
 
-      e = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, "test message")
+      e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
       e.write(prot)
     end
 
     it "should skip nil fields when writing to the oprot" do
       prot = mock("MockProtocol")
       prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
-      prot.should_receive(:write_field_begin).with("message", Types::STRING, 1).ordered
+      prot.should_receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
       prot.should_receive(:write_string).with("test message").ordered
       prot.should_receive(:write_field_end).ordered
       prot.should_receive(:write_field_stop).ordered
       prot.should_receive(:write_struct_end).ordered
 
-      e = ApplicationException.new(nil, "test message")
+      e = Thrift::ApplicationException.new(nil, "test message")
       e.write(prot)
 
       prot = mock("MockProtocol")
       prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
-      prot.should_receive(:write_field_begin).with("type", Types::I32, 2).ordered
-      prot.should_receive(:write_i32).with(ApplicationException::BAD_SEQUENCE_ID).ordered
+      prot.should_receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
+      prot.should_receive(:write_i32).with(Thrift::ApplicationException::BAD_SEQUENCE_ID).ordered
       prot.should_receive(:write_field_end).ordered
       prot.should_receive(:write_field_stop).ordered
       prot.should_receive(:write_struct_end).ordered
 
-      e = ApplicationException.new(ApplicationException::BAD_SEQUENCE_ID)
+      e = Thrift::ApplicationException.new(Thrift::ApplicationException::BAD_SEQUENCE_ID)
       e.write(prot)
 
       prot = mock("MockProtocol")
@@ -127,15 +126,15 @@ class ThriftExceptionSpec < Spec::Exampl
       prot.should_receive(:write_field_stop).ordered
       prot.should_receive(:write_struct_end).ordered
 
-      e = ApplicationException.new(nil)
+      e = Thrift::ApplicationException.new(nil)
       e.write(prot)
     end
   end
 
-  describe ProtocolException do
+  describe Thrift::ProtocolException do
     it "should have an accessible type" do
-      prot = ProtocolException.new(ProtocolException::SIZE_LIMIT, "message")
-      prot.type.should == ProtocolException::SIZE_LIMIT
+      prot = Thrift::ProtocolException.new(Thrift::ProtocolException::SIZE_LIMIT, "message")
+      prot.type.should == Thrift::ProtocolException::SIZE_LIMIT
       prot.message.should == "message"
     end
   end

Modified: thrift/trunk/lib/rb/spec/http_client_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/http_client_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/http_client_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/http_client_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,14 +17,13 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftHTTPClientTransportSpec < Spec::ExampleGroup
-  include Thrift
+describe 'Thrift::HTTPClientTransport' do
 
-  describe HTTPClientTransport do
+  describe Thrift::HTTPClientTransport do
     before(:each) do
-      @client = HTTPClientTransport.new("http://my.domain.com/path/to/service?param=value")
+      @client = Thrift::HTTPClientTransport.new("http://my.domain.com/path/to/service?param=value")
     end
 
     it "should always be open" do

Modified: thrift/trunk/lib/rb/spec/json_protocol_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/json_protocol_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/json_protocol_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/json_protocol_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,463 +17,464 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftJsonProtocolSpec < Spec::ExampleGroup
-  include Thrift
+describe 'JsonProtocol' do
 
-  before(:each) do
-    @trans = Thrift::MemoryBufferTransport.new
-    @prot = JsonProtocol.new(@trans)
-  end
+  describe Thrift::JsonProtocol do
+    before(:each) do
+      @trans = Thrift::MemoryBufferTransport.new
+      @prot = Thrift::JsonProtocol.new(@trans)
+    end
 
-  it "should write json escaped char" do
-    @prot.write_json_escape_char("\n")
-    @trans.read(@trans.available).should == '\u000a'
+    it "should write json escaped char" do
+      @prot.write_json_escape_char("\n")
+      @trans.read(@trans.available).should == '\u000a'
 
-    @prot.write_json_escape_char(" ")
-    @trans.read(@trans.available).should == '\u0020'
-  end
+      @prot.write_json_escape_char(" ")
+      @trans.read(@trans.available).should == '\u0020'
+    end
 
-  it "should write json char" do
-    @prot.write_json_char("\n")
-    @trans.read(@trans.available).should == '\\n'
+    it "should write json char" do
+      @prot.write_json_char("\n")
+      @trans.read(@trans.available).should == '\\n'
 
-    @prot.write_json_char(" ")
-    @trans.read(@trans.available).should == ' '
+      @prot.write_json_char(" ")
+      @trans.read(@trans.available).should == ' '
 
-    @prot.write_json_char("\\")
-    @trans.read(@trans.available).should == "\\\\"
+      @prot.write_json_char("\\")
+      @trans.read(@trans.available).should == "\\\\"
 
-    @prot.write_json_char("@")
-    @trans.read(@trans.available).should == '@'
-  end
+      @prot.write_json_char("@")
+      @trans.read(@trans.available).should == '@'
+    end
 
-  it "should write json string" do
-    @prot.write_json_string("this is a \\ json\nstring")
-    @trans.read(@trans.available).should == "\"this is a \\\\ json\\nstring\""
-  end
+    it "should write json string" do
+      @prot.write_json_string("this is a \\ json\nstring")
+      @trans.read(@trans.available).should == "\"this is a \\\\ json\\nstring\""
+    end
 
-  it "should write json base64" do
-    @prot.write_json_base64("this is a base64 string")
-    @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
-  end
+    it "should write json base64" do
+      @prot.write_json_base64("this is a base64 string")
+      @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
+    end
 
-  it "should write json integer" do
-    @prot.write_json_integer(45)
-    @trans.read(@trans.available).should == "45"
+    it "should write json integer" do
+      @prot.write_json_integer(45)
+      @trans.read(@trans.available).should == "45"
 
-    @prot.write_json_integer(33000)
-    @trans.read(@trans.available).should == "33000"
+      @prot.write_json_integer(33000)
+      @trans.read(@trans.available).should == "33000"
 
-    @prot.write_json_integer(3000000000)
-    @trans.read(@trans.available).should == "3000000000"
+      @prot.write_json_integer(3000000000)
+      @trans.read(@trans.available).should == "3000000000"
 
-    @prot.write_json_integer(6000000000)
-    @trans.read(@trans.available).should == "6000000000"
-  end
+      @prot.write_json_integer(6000000000)
+      @trans.read(@trans.available).should == "6000000000"
+    end
 
-  it "should write json double" do
-    @prot.write_json_double(12.3)
-    @trans.read(@trans.available).should == "12.3"
+    it "should write json double" do
+      @prot.write_json_double(12.3)
+      @trans.read(@trans.available).should == "12.3"
 
-    @prot.write_json_double(-3.21)
-    @trans.read(@trans.available).should == "-3.21"
+      @prot.write_json_double(-3.21)
+      @trans.read(@trans.available).should == "-3.21"
 
-    @prot.write_json_double(((+1.0/0.0)/(+1.0/0.0)))
-    @trans.read(@trans.available).should == "\"NaN\""
+      @prot.write_json_double(((+1.0/0.0)/(+1.0/0.0)))
+      @trans.read(@trans.available).should == "\"NaN\""
 
-    @prot.write_json_double((+1.0/0.0))
-    @trans.read(@trans.available).should == "\"Infinity\""
+      @prot.write_json_double((+1.0/0.0))
+      @trans.read(@trans.available).should == "\"Infinity\""
 
-    @prot.write_json_double((-1.0/0.0))
-    @trans.read(@trans.available).should == "\"-Infinity\""
-  end
+      @prot.write_json_double((-1.0/0.0))
+      @trans.read(@trans.available).should == "\"-Infinity\""
+    end
 
-  it "should write json object start" do
-    @prot.write_json_object_start
-    @trans.read(@trans.available).should == "{"
-  end
+    it "should write json object start" do
+      @prot.write_json_object_start
+      @trans.read(@trans.available).should == "{"
+    end
 
-  it "should write json object end" do
-    @prot.write_json_object_end
-    @trans.read(@trans.available).should == "}"
-  end
+    it "should write json object end" do
+      @prot.write_json_object_end
+      @trans.read(@trans.available).should == "}"
+    end
 
-  it "should write json array start" do
-    @prot.write_json_array_start
-    @trans.read(@trans.available).should == "["
-  end
+    it "should write json array start" do
+      @prot.write_json_array_start
+      @trans.read(@trans.available).should == "["
+    end
 
-  it "should write json array end" do
-    @prot.write_json_array_end
-    @trans.read(@trans.available).should == "]"
-  end
+    it "should write json array end" do
+      @prot.write_json_array_end
+      @trans.read(@trans.available).should == "]"
+    end
 
-  it "should write message begin" do
-    @prot.write_message_begin("name", 12, 32)
-    @trans.read(@trans.available).should == "[1,\"name\",12,32"
-  end
+    it "should write message begin" do
+      @prot.write_message_begin("name", 12, 32)
+      @trans.read(@trans.available).should == "[1,\"name\",12,32"
+    end
 
-  it "should write message end" do
-    @prot.write_message_end
-    @trans.read(@trans.available).should == "]"
-  end
+    it "should write message end" do
+      @prot.write_message_end
+      @trans.read(@trans.available).should == "]"
+    end
 
-  it "should write struct begin" do
-    @prot.write_struct_begin("name")
-    @trans.read(@trans.available).should == "{"
-  end
+    it "should write struct begin" do
+      @prot.write_struct_begin("name")
+      @trans.read(@trans.available).should == "{"
+    end
 
-  it "should write struct end" do
-    @prot.write_struct_end
-    @trans.read(@trans.available).should == "}"
-  end
+    it "should write struct end" do
+      @prot.write_struct_end
+      @trans.read(@trans.available).should == "}"
+    end
 
-  it "should write field begin" do
-    @prot.write_field_begin("name", Types::STRUCT, 32)
-    @trans.read(@trans.available).should == "32{\"rec\""
-  end
+    it "should write field begin" do
+      @prot.write_field_begin("name", Thrift::Types::STRUCT, 32)
+      @trans.read(@trans.available).should == "32{\"rec\""
+    end
 
-  it "should write field end" do
-    @prot.write_field_end
-    @trans.read(@trans.available).should == "}"
-  end
+    it "should write field end" do
+      @prot.write_field_end
+      @trans.read(@trans.available).should == "}"
+    end
 
-  it "should write field stop" do
-    @prot.write_field_stop
-    @trans.read(@trans.available).should == ""
-  end
+    it "should write field stop" do
+      @prot.write_field_stop
+      @trans.read(@trans.available).should == ""
+    end
 
-  it "should write map begin" do
-    @prot.write_map_begin(Types::STRUCT, Types::LIST, 32)
-    @trans.read(@trans.available).should == "[\"rec\",\"lst\",32,{"
-  end
+    it "should write map begin" do
+      @prot.write_map_begin(Thrift::Types::STRUCT, Thrift::Types::LIST, 32)
+      @trans.read(@trans.available).should == "[\"rec\",\"lst\",32,{"
+    end
 
-  it "should write map end" do
-    @prot.write_map_end
-    @trans.read(@trans.available).should == "}]"
-  end
+    it "should write map end" do
+      @prot.write_map_end
+      @trans.read(@trans.available).should == "}]"
+    end
 
-  it "should write list begin" do
-    @prot.write_list_begin(Types::STRUCT, 32)
-    @trans.read(@trans.available).should == "[\"rec\",32"
-  end
+    it "should write list begin" do
+      @prot.write_list_begin(Thrift::Types::STRUCT, 32)
+      @trans.read(@trans.available).should == "[\"rec\",32"
+    end
 
-  it "should write list end" do
-    @prot.write_list_end
-    @trans.read(@trans.available).should == "]"
-  end
+    it "should write list end" do
+      @prot.write_list_end
+      @trans.read(@trans.available).should == "]"
+    end
 
-  it "should write set begin" do
-    @prot.write_set_begin(Types::STRUCT, 32)
-    @trans.read(@trans.available).should == "[\"rec\",32"
-  end
+    it "should write set begin" do
+      @prot.write_set_begin(Thrift::Types::STRUCT, 32)
+      @trans.read(@trans.available).should == "[\"rec\",32"
+    end
 
-  it "should write set end" do
-    @prot.write_set_end
-    @trans.read(@trans.available).should == "]"
-  end
+    it "should write set end" do
+      @prot.write_set_end
+      @trans.read(@trans.available).should == "]"
+    end
 
-  it "should write bool" do
-    @prot.write_bool(true)
-    @trans.read(@trans.available).should == "1"
+    it "should write bool" do
+      @prot.write_bool(true)
+      @trans.read(@trans.available).should == "1"
 
-    @prot.write_bool(false)
-    @trans.read(@trans.available).should == "0"
-  end
+      @prot.write_bool(false)
+      @trans.read(@trans.available).should == "0"
+    end
 
-  it "should write byte" do
-    @prot.write_byte(100)
-    @trans.read(@trans.available).should == "100"
-  end
+    it "should write byte" do
+      @prot.write_byte(100)
+      @trans.read(@trans.available).should == "100"
+    end
 
-  it "should write i16" do
-    @prot.write_i16(1000)
-    @trans.read(@trans.available).should == "1000"
-  end
+    it "should write i16" do
+      @prot.write_i16(1000)
+      @trans.read(@trans.available).should == "1000"
+    end
 
-  it "should write i32" do
-    @prot.write_i32(3000000000)
-    @trans.read(@trans.available).should == "3000000000"
-  end
+    it "should write i32" do
+      @prot.write_i32(3000000000)
+      @trans.read(@trans.available).should == "3000000000"
+    end
 
-  it "should write i64" do
-    @prot.write_i64(6000000000)
-    @trans.read(@trans.available).should == "6000000000"
-  end
+    it "should write i64" do
+      @prot.write_i64(6000000000)
+      @trans.read(@trans.available).should == "6000000000"
+    end
 
-  it "should write double" do
-    @prot.write_double(1.23)
-    @trans.read(@trans.available).should == "1.23"
+    it "should write double" do
+      @prot.write_double(1.23)
+      @trans.read(@trans.available).should == "1.23"
 
-    @prot.write_double(-32.1)
-    @trans.read(@trans.available).should == "-32.1"
+      @prot.write_double(-32.1)
+      @trans.read(@trans.available).should == "-32.1"
 
-    @prot.write_double(((+1.0/0.0)/(+1.0/0.0)))
-    @trans.read(@trans.available).should == "\"NaN\""
+      @prot.write_double(((+1.0/0.0)/(+1.0/0.0)))
+      @trans.read(@trans.available).should == "\"NaN\""
 
-    @prot.write_double((+1.0/0.0))
-    @trans.read(@trans.available).should == "\"Infinity\""
+      @prot.write_double((+1.0/0.0))
+      @trans.read(@trans.available).should == "\"Infinity\""
 
-    @prot.write_double((-1.0/0.0))
-    @trans.read(@trans.available).should == "\"-Infinity\""
-  end
+      @prot.write_double((-1.0/0.0))
+      @trans.read(@trans.available).should == "\"-Infinity\""
+    end
 
-  it "should write string" do
-    @prot.write_string("this is a test string")
-    @trans.read(@trans.available).should == "\"this is a test string\""
-  end
+    it "should write string" do
+      @prot.write_string("this is a test string")
+      @trans.read(@trans.available).should == "\"this is a test string\""
+    end
 
-  it "should write binary" do
-    @prot.write_binary("this is a base64 string")
-    @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
-  end
+    it "should write binary" do
+      @prot.write_binary("this is a base64 string")
+      @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
+    end
 
-  it "should get type name for type id" do
-    expect {@prot.get_type_name_for_type_id(Types::STOP)}.to raise_error(NotImplementedError)
-    expect {@prot.get_type_name_for_type_id(Types::VOID)}.to raise_error(NotImplementedError)
-    @prot.get_type_name_for_type_id(Types::BOOL).should == "tf"
-    @prot.get_type_name_for_type_id(Types::BYTE).should == "i8"
-    @prot.get_type_name_for_type_id(Types::DOUBLE).should == "dbl"
-    @prot.get_type_name_for_type_id(Types::I16).should == "i16"
-    @prot.get_type_name_for_type_id(Types::I32).should == "i32"
-    @prot.get_type_name_for_type_id(Types::I64).should == "i64"
-    @prot.get_type_name_for_type_id(Types::STRING).should == "str"
-    @prot.get_type_name_for_type_id(Types::STRUCT).should == "rec"
-    @prot.get_type_name_for_type_id(Types::MAP).should == "map"
-    @prot.get_type_name_for_type_id(Types::SET).should == "set"
-    @prot.get_type_name_for_type_id(Types::LIST).should == "lst"
-  end
+    it "should get type name for type id" do
+      expect {@prot.get_type_name_for_type_id(Thrift::Types::STOP)}.to raise_error(NotImplementedError)
+      expect {@prot.get_type_name_for_type_id(Thrift::Types::VOID)}.to raise_error(NotImplementedError)
+      @prot.get_type_name_for_type_id(Thrift::Types::BOOL).should == "tf"
+      @prot.get_type_name_for_type_id(Thrift::Types::BYTE).should == "i8"
+      @prot.get_type_name_for_type_id(Thrift::Types::DOUBLE).should == "dbl"
+      @prot.get_type_name_for_type_id(Thrift::Types::I16).should == "i16"
+      @prot.get_type_name_for_type_id(Thrift::Types::I32).should == "i32"
+      @prot.get_type_name_for_type_id(Thrift::Types::I64).should == "i64"
+      @prot.get_type_name_for_type_id(Thrift::Types::STRING).should == "str"
+      @prot.get_type_name_for_type_id(Thrift::Types::STRUCT).should == "rec"
+      @prot.get_type_name_for_type_id(Thrift::Types::MAP).should == "map"
+      @prot.get_type_name_for_type_id(Thrift::Types::SET).should == "set"
+      @prot.get_type_name_for_type_id(Thrift::Types::LIST).should == "lst"
+    end
 
-  it "should get type id for type name" do
-    expect {@prot.get_type_id_for_type_name("pp")}.to raise_error(NotImplementedError)
-    @prot.get_type_id_for_type_name("tf").should == Types::BOOL
-    @prot.get_type_id_for_type_name("i8").should == Types::BYTE
-    @prot.get_type_id_for_type_name("dbl").should == Types::DOUBLE
-    @prot.get_type_id_for_type_name("i16").should == Types::I16
-    @prot.get_type_id_for_type_name("i32").should == Types::I32
-    @prot.get_type_id_for_type_name("i64").should == Types::I64
-    @prot.get_type_id_for_type_name("str").should == Types::STRING
-    @prot.get_type_id_for_type_name("rec").should == Types::STRUCT
-    @prot.get_type_id_for_type_name("map").should == Types::MAP
-    @prot.get_type_id_for_type_name("set").should == Types::SET
-    @prot.get_type_id_for_type_name("lst").should == Types::LIST
-  end
+    it "should get type id for type name" do
+      expect {@prot.get_type_id_for_type_name("pp")}.to raise_error(NotImplementedError)
+      @prot.get_type_id_for_type_name("tf").should == Thrift::Types::BOOL
+      @prot.get_type_id_for_type_name("i8").should == Thrift::Types::BYTE
+      @prot.get_type_id_for_type_name("dbl").should == Thrift::Types::DOUBLE
+      @prot.get_type_id_for_type_name("i16").should == Thrift::Types::I16
+      @prot.get_type_id_for_type_name("i32").should == Thrift::Types::I32
+      @prot.get_type_id_for_type_name("i64").should == Thrift::Types::I64
+      @prot.get_type_id_for_type_name("str").should == Thrift::Types::STRING
+      @prot.get_type_id_for_type_name("rec").should == Thrift::Types::STRUCT
+      @prot.get_type_id_for_type_name("map").should == Thrift::Types::MAP
+      @prot.get_type_id_for_type_name("set").should == Thrift::Types::SET
+      @prot.get_type_id_for_type_name("lst").should == Thrift::Types::LIST
+    end
 
-  it "should read json syntax char" do
-    @trans.write('F')
-    expect {@prot.read_json_syntax_char('G')}.to raise_error(ProtocolException)
-    @trans.write('H')
-    @prot.read_json_syntax_char('H')
-  end
+    it "should read json syntax char" do
+      @trans.write('F')
+      expect {@prot.read_json_syntax_char('G')}.to raise_error(Thrift::ProtocolException)
+      @trans.write('H')
+      @prot.read_json_syntax_char('H')
+    end
 
-  it "should read json escape char" do
-    @trans.write('0054')
-    @prot.read_json_escape_char.should == 'T'
-  end
+    it "should read json escape char" do
+      @trans.write('0054')
+      @prot.read_json_escape_char.should == 'T'
+    end
 
-  it "should read json string" do
-    @trans.write("\"\\P")
-    expect {@prot.read_json_string(false)}.to raise_error(ProtocolException)
+    it "should read json string" do
+      @trans.write("\"\\P")
+      expect {@prot.read_json_string(false)}.to raise_error(Thrift::ProtocolException)
 
-    @trans.write("\"\\n\"")
-    @prot.read_json_string(false).should == "\\n"
+      @trans.write("\"\\n\"")
+      @prot.read_json_string(false).should == "\\n"
 
-    @trans.write("\"this is a test string\"")
-    @prot.read_json_string.should == "this is a test string"
-  end
+      @trans.write("\"this is a test string\"")
+      @prot.read_json_string.should == "this is a test string"
+    end
 
-  it "should read json base64" do
-    @trans.write("\"dGhpcyBpcyBhIHRlc3Qgc3RyaW5n\"")
-    @prot.read_json_base64.should == "this is a test string"
-  end
+    it "should read json base64" do
+      @trans.write("\"dGhpcyBpcyBhIHRlc3Qgc3RyaW5n\"")
+      @prot.read_json_base64.should == "this is a test string"
+    end
 
-  it "should is json numeric" do
-    @prot.is_json_numeric("A").should == false
-    @prot.is_json_numeric("+").should == true
-    @prot.is_json_numeric("-").should == true
-    @prot.is_json_numeric(".").should == true
-    @prot.is_json_numeric("0").should == true
-    @prot.is_json_numeric("1").should == true
-    @prot.is_json_numeric("2").should == true
-    @prot.is_json_numeric("3").should == true
-    @prot.is_json_numeric("4").should == true
-    @prot.is_json_numeric("5").should == true
-    @prot.is_json_numeric("6").should == true
-    @prot.is_json_numeric("7").should == true
-    @prot.is_json_numeric("8").should == true
-    @prot.is_json_numeric("9").should == true
-    @prot.is_json_numeric("E").should == true
-    @prot.is_json_numeric("e").should == true
-  end
+    it "should is json numeric" do
+      @prot.is_json_numeric("A").should == false
+      @prot.is_json_numeric("+").should == true
+      @prot.is_json_numeric("-").should == true
+      @prot.is_json_numeric(".").should == true
+      @prot.is_json_numeric("0").should == true
+      @prot.is_json_numeric("1").should == true
+      @prot.is_json_numeric("2").should == true
+      @prot.is_json_numeric("3").should == true
+      @prot.is_json_numeric("4").should == true
+      @prot.is_json_numeric("5").should == true
+      @prot.is_json_numeric("6").should == true
+      @prot.is_json_numeric("7").should == true
+      @prot.is_json_numeric("8").should == true
+      @prot.is_json_numeric("9").should == true
+      @prot.is_json_numeric("E").should == true
+      @prot.is_json_numeric("e").should == true
+    end
 
-  it "should read json numeric chars" do
-    @trans.write("1.453E45T")
-    @prot.read_json_numeric_chars.should == "1.453E45"
-  end
+    it "should read json numeric chars" do
+      @trans.write("1.453E45T")
+      @prot.read_json_numeric_chars.should == "1.453E45"
+    end
 
-  it "should read json integer" do
-    @trans.write("1.45\"\"")
-    expect {@prot.read_json_integer}.to raise_error(ProtocolException)
-    @prot.read_string
+    it "should read json integer" do
+      @trans.write("1.45\"\"")
+      expect {@prot.read_json_integer}.to raise_error(Thrift::ProtocolException)
+      @prot.read_string
 
-    @trans.write("1453T")
-    @prot.read_json_integer.should == 1453
-  end
+      @trans.write("1453T")
+      @prot.read_json_integer.should == 1453
+    end
 
-  it "should read json double" do
-    @trans.write("1.45e3e01\"\"")
-    expect {@prot.read_json_double}.to raise_error(ProtocolException)
-    @prot.read_string
-
-    @trans.write("\"1.453e01\"")
-    expect {@prot.read_json_double}.to raise_error(ProtocolException)
-
-    @trans.write("1.453e01\"\"")
-    @prot.read_json_double.should == 14.53
-    @prot.read_string
+    it "should read json double" do
+      @trans.write("1.45e3e01\"\"")
+      expect {@prot.read_json_double}.to raise_error(Thrift::ProtocolException)
+      @prot.read_string
+
+      @trans.write("\"1.453e01\"")
+      expect {@prot.read_json_double}.to raise_error(Thrift::ProtocolException)
+
+      @trans.write("1.453e01\"\"")
+      @prot.read_json_double.should == 14.53
+      @prot.read_string
 
-    @trans.write("\"NaN\"")
-    @prot.read_json_double.nan?.should == true
+      @trans.write("\"NaN\"")
+      @prot.read_json_double.nan?.should == true
 
-    @trans.write("\"Infinity\"")
-    @prot.read_json_double.should == +1.0/0.0
+      @trans.write("\"Infinity\"")
+      @prot.read_json_double.should == +1.0/0.0
 
-    @trans.write("\"-Infinity\"")
-    @prot.read_json_double.should == -1.0/0.0
-  end
+      @trans.write("\"-Infinity\"")
+      @prot.read_json_double.should == -1.0/0.0
+    end
 
-  it "should read json object start" do
-    @trans.write("{")
-    @prot.read_json_object_start.should == nil
-  end
+    it "should read json object start" do
+      @trans.write("{")
+      @prot.read_json_object_start.should == nil
+    end
 
-  it "should read json object end" do
-    @trans.write("}")
-    @prot.read_json_object_end.should == nil
-  end
+    it "should read json object end" do
+      @trans.write("}")
+      @prot.read_json_object_end.should == nil
+    end
 
-  it "should read json array start" do
-    @trans.write("[")
-    @prot.read_json_array_start.should == nil
-  end
+    it "should read json array start" do
+      @trans.write("[")
+      @prot.read_json_array_start.should == nil
+    end
 
-  it "should read json array end" do
-    @trans.write("]")
-    @prot.read_json_array_end.should == nil
-  end
+    it "should read json array end" do
+      @trans.write("]")
+      @prot.read_json_array_end.should == nil
+    end
 
-  it "should read_message_begin" do
-    @trans.write("[2,")
-    expect {@prot.read_message_begin}.to raise_error(ProtocolException)
+    it "should read_message_begin" do
+      @trans.write("[2,")
+      expect {@prot.read_message_begin}.to raise_error(Thrift::ProtocolException)
 
-    @trans.write("[1,\"name\",12,32\"\"")
-    @prot.read_message_begin.should == ["name", 12, 32]
-  end
+      @trans.write("[1,\"name\",12,32\"\"")
+      @prot.read_message_begin.should == ["name", 12, 32]
+    end
 
-  it "should read message end" do
-    @trans.write("]")
-    @prot.read_message_end.should == nil
-  end
+    it "should read message end" do
+      @trans.write("]")
+      @prot.read_message_end.should == nil
+    end
 
-  it "should read struct begin" do
-    @trans.write("{")
-    @prot.read_struct_begin.should == nil
-  end
+    it "should read struct begin" do
+      @trans.write("{")
+      @prot.read_struct_begin.should == nil
+    end
 
-  it "should read struct end" do
-    @trans.write("}")
-    @prot.read_struct_end.should == nil
-  end
+    it "should read struct end" do
+      @trans.write("}")
+      @prot.read_struct_end.should == nil
+    end
 
-  it "should read field begin" do
-    @trans.write("1{\"rec\"")
-    @prot.read_field_begin.should == [nil, 12, 1]
-  end
+    it "should read field begin" do
+      @trans.write("1{\"rec\"")
+      @prot.read_field_begin.should == [nil, 12, 1]
+    end
 
-  it "should read field end" do
-    @trans.write("}")
-    @prot.read_field_end.should == nil
-  end
+    it "should read field end" do
+      @trans.write("}")
+      @prot.read_field_end.should == nil
+    end
 
-  it "should read map begin" do
-    @trans.write("[\"rec\",\"lst\",2,{")
-    @prot.read_map_begin.should == [12, 15, 2]
-  end
+    it "should read map begin" do
+      @trans.write("[\"rec\",\"lst\",2,{")
+      @prot.read_map_begin.should == [12, 15, 2]
+    end
 
-  it "should read map end" do
-    @trans.write("}]")
-    @prot.read_map_end.should == nil
-  end
+    it "should read map end" do
+      @trans.write("}]")
+      @prot.read_map_end.should == nil
+    end
 
-  it "should read list begin" do
-    @trans.write("[\"rec\",2\"\"")
-    @prot.read_list_begin.should == [12, 2]
-  end
+    it "should read list begin" do
+      @trans.write("[\"rec\",2\"\"")
+      @prot.read_list_begin.should == [12, 2]
+    end
 
-  it "should read list end" do
-    @trans.write("]")
-    @prot.read_list_end.should == nil
-  end
+    it "should read list end" do
+      @trans.write("]")
+      @prot.read_list_end.should == nil
+    end
 
-  it "should read set begin" do
-    @trans.write("[")
-    @prot.read_set_begin.should == nil
-  end
+    it "should read set begin" do
+      @trans.write("[")
+      @prot.read_set_begin.should == nil
+    end
 
-  it "should read set end" do
-    @trans.write("]")
-    @prot.read_set_end.should == nil
-  end
+    it "should read set end" do
+      @trans.write("]")
+      @prot.read_set_end.should == nil
+    end
 
-  it "should read bool" do
-    @trans.write("0\"\"")
-    @prot.read_bool.should == false
-    @prot.read_string
+    it "should read bool" do
+      @trans.write("0\"\"")
+      @prot.read_bool.should == false
+      @prot.read_string
 
-    @trans.write("1\"\"")
-    @prot.read_bool.should == true
-  end
+      @trans.write("1\"\"")
+      @prot.read_bool.should == true
+    end
 
-  it "should read byte" do
-    @trans.write("60\"\"")
-    @prot.read_byte.should == 60
-  end
+    it "should read byte" do
+      @trans.write("60\"\"")
+      @prot.read_byte.should == 60
+    end
 
-  it "should read i16" do
-    @trans.write("1000\"\"")
-    @prot.read_i16.should == 1000
-  end
+    it "should read i16" do
+      @trans.write("1000\"\"")
+      @prot.read_i16.should == 1000
+    end
 
-  it "should read i32" do
-    @trans.write("3000000000\"\"")
-    @prot.read_i32.should == 3000000000
-  end
+    it "should read i32" do
+      @trans.write("3000000000\"\"")
+      @prot.read_i32.should == 3000000000
+    end
 
-  it "should read i64" do
-    @trans.write("6000000000\"\"")
-    @prot.read_i64.should == 6000000000
-  end
+    it "should read i64" do
+      @trans.write("6000000000\"\"")
+      @prot.read_i64.should == 6000000000
+    end
 
-  it "should read double" do
-    @trans.write("12.23\"\"")
-    @prot.read_double.should == 12.23
-  end
+    it "should read double" do
+      @trans.write("12.23\"\"")
+      @prot.read_double.should == 12.23
+    end
 
-  it "should read string" do
-    @trans.write("\"this is a test string\"")
-    @prot.read_string.should == "this is a test string"
-  end
+    it "should read string" do
+      @trans.write("\"this is a test string\"")
+      @prot.read_string.should == "this is a test string"
+    end
 
-  it "should read binary" do
-    @trans.write("\"dGhpcyBpcyBhIHRlc3Qgc3RyaW5n\"")
-    @prot.read_binary.should == "this is a test string"
+    it "should read binary" do
+      @trans.write("\"dGhpcyBpcyBhIHRlc3Qgc3RyaW5n\"")
+      @prot.read_binary.should == "this is a test string"
+    end
   end
 
-  describe JsonProtocolFactory do
+  describe Thrift::JsonProtocolFactory do
     it "should create a JsonProtocol" do
-      JsonProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(JsonProtocol)
+      Thrift::JsonProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::JsonProtocol)
     end
   end
 end

Modified: thrift/trunk/lib/rb/spec/mongrel_http_server_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/mongrel_http_server_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/mongrel_http_server_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/mongrel_http_server_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,27 +17,24 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 require 'thrift/server/mongrel_http_server'
 
-class ThriftHTTPServerSpec < Spec::ExampleGroup
-  include Thrift
+describe 'HTTPServer' do
 
-  Handler = MongrelHTTPServer::Handler
-
-  describe MongrelHTTPServer do
+  describe Thrift::MongrelHTTPServer do
     it "should have appropriate defaults" do
       mock_factory = mock("BinaryProtocolFactory")
       mock_proc = mock("Processor")
-      BinaryProtocolFactory.should_receive(:new).and_return(mock_factory)
+      Thrift::BinaryProtocolFactory.should_receive(:new).and_return(mock_factory)
       Mongrel::HttpServer.should_receive(:new).with("0.0.0.0", 80).and_return do
         mock("Mongrel::HttpServer").tee do |mock|
           handler = mock("Handler")
-          Handler.should_receive(:new).with(mock_proc, mock_factory).and_return(handler)
+          Thrift::MongrelHTTPServer::Handler.should_receive(:new).with(mock_proc, mock_factory).and_return(handler)
           mock.should_receive(:register).with("/", handler)
         end
       end
-      MongrelHTTPServer.new(mock_proc)
+      Thrift::MongrelHTTPServer.new(mock_proc)
     end
 
     it "should understand :ip, :port, :path, and :protocol_factory" do
@@ -46,19 +43,19 @@ class ThriftHTTPServerSpec < Spec::Examp
       Mongrel::HttpServer.should_receive(:new).with("1.2.3.4", 1234).and_return do
         mock("Mongrel::HttpServer").tee do |mock|
           handler = mock("Handler")
-          Handler.should_receive(:new).with(mock_proc, mock_factory).and_return(handler)
+          Thrift::MongrelHTTPServer::Handler.should_receive(:new).with(mock_proc, mock_factory).and_return(handler)
           mock.should_receive(:register).with("/foo", handler)
         end
       end
-      MongrelHTTPServer.new(mock_proc, :ip => "1.2.3.4", :port => 1234, :path => "foo",
+      Thrift::MongrelHTTPServer.new(mock_proc, :ip => "1.2.3.4", :port => 1234, :path => "foo",
                                              :protocol_factory => mock_factory)
     end
 
     it "should serve using Mongrel::HttpServer" do
-      BinaryProtocolFactory.stub!(:new)
+      Thrift::BinaryProtocolFactory.stub!(:new)
       Mongrel::HttpServer.should_receive(:new).and_return do
         mock("Mongrel::HttpServer").tee do |mock|
-          Handler.stub!(:new)
+          Thrift::MongrelHTTPServer::Handler.stub!(:new)
           mock.stub!(:register)
           mock.should_receive(:run).and_return do
             mock("Mongrel::HttpServer.run").tee do |runner|
@@ -67,15 +64,15 @@ class ThriftHTTPServerSpec < Spec::Examp
           end
         end
       end
-      MongrelHTTPServer.new(nil).serve
+      Thrift::MongrelHTTPServer.new(nil).serve
     end
   end
 
-  describe MongrelHTTPServer::Handler do
+  describe Thrift::MongrelHTTPServer::Handler do
     before(:each) do
       @processor = mock("Processor")
       @factory = mock("ProtocolFactory")
-      @handler = Handler.new(@processor, @factory)
+      @handler = described_class.new(@processor, @factory)
     end
 
     it "should return 404 for non-POST requests" do
@@ -91,7 +88,7 @@ class ThriftHTTPServerSpec < Spec::Examp
       response = mock("response")
       head = mock("head")
       head.should_receive(:[]=).with("Content-Type", "application/x-thrift")
-      IOStreamTransport.stub!(:new)
+      Thrift::IOStreamTransport.stub!(:new)
       @factory.stub!(:get_protocol)
       @processor.stub!(:process)
       response.should_receive(:start).with(200).and_yield(head, nil)
@@ -107,7 +104,7 @@ class ThriftHTTPServerSpec < Spec::Examp
       out = mock("out")
       protocol = mock("protocol")
       transport = mock("transport")
-      IOStreamTransport.should_receive(:new).with(body, out).and_return(transport)
+      Thrift::IOStreamTransport.should_receive(:new).with(body, out).and_return(transport)
       @factory.should_receive(:get_protocol).with(transport).and_return(protocol)
       @processor.should_receive(:process).with(protocol, protocol)
       response.should_receive(:start).with(200).and_yield(head, out)

Modified: thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,11 +17,9 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftNonblockingServerSpec < Spec::ExampleGroup
-  include Thrift
-  include SpecNamespace
+describe 'NonblockingServer' do
 
   class Handler
     def initialize
@@ -55,7 +53,7 @@ class ThriftNonblockingServerSpec < Spec
     end
   end
 
-  class SpecTransport < BaseTransport
+  class SpecTransport < Thrift::BaseTransport
     def initialize(transport, queue)
       @transport = transport
       @queue = queue
@@ -89,7 +87,7 @@ class ThriftNonblockingServerSpec < Spec
     end
   end
 
-  class SpecServerSocket < ServerSocket
+  class SpecServerSocket < Thrift::ServerSocket
     def initialize(host, port, queue)
       super(host, port)
       @queue = queue
@@ -105,13 +103,13 @@ class ThriftNonblockingServerSpec < Spec
     before(:each) do
       @port = 43251
       handler = Handler.new
-      processor = NonblockingService::Processor.new(handler)
+      processor = SpecNamespace::NonblockingService::Processor.new(handler)
       queue = Queue.new
       @transport = SpecServerSocket.new('localhost', @port, queue)
-      transport_factory = FramedTransportFactory.new
+      transport_factory = Thrift::FramedTransportFactory.new
       logger = Logger.new(STDERR)
       logger.level = Logger::WARN
-      @server = NonblockingServer.new(processor, @transport, transport_factory, nil, 5, logger)
+      @server = Thrift::NonblockingServer.new(processor, @transport, transport_factory, nil, 5, logger)
       handler.server = @server
       @server_thread = Thread.new(Thread.current) do |master_thread|
         begin
@@ -136,9 +134,9 @@ class ThriftNonblockingServerSpec < Spec
     end
 
     def setup_client(queue = nil)
-      transport = SpecTransport.new(FramedTransport.new(Socket.new('localhost', @port)), queue)
-      protocol = BinaryProtocol.new(transport)
-      client = NonblockingService::Client.new(protocol)
+      transport = SpecTransport.new(Thrift::FramedTransport.new(Thrift::Socket.new('localhost', @port)), queue)
+      protocol = Thrift::BinaryProtocol.new(transport)
+      client = SpecNamespace::NonblockingService::Client.new(protocol)
       transport.open
       @clients << [client, transport]
       client
@@ -178,8 +176,8 @@ class ThriftNonblockingServerSpec < Spec
 
     it "should handle basic message passing" do
       client = setup_client
-      client.greeting(true).should == Hello.new
-      client.greeting(false).should == Hello.new(:greeting => 'Aloha!')
+      client.greeting(true).should == SpecNamespace::Hello.new
+      client.greeting(false).should == SpecNamespace::Hello.new(:greeting => 'Aloha!')
       @server.shutdown
     end
 
@@ -214,15 +212,15 @@ class ThriftNonblockingServerSpec < Spec
       queues[4] << :hello
       queues[5] << :hello
       queues[6] << :hello
-      3.times { result.pop.should == Hello.new }
-      client.greeting(true).should == Hello.new
+      3.times { result.pop.should == SpecNamespace::Hello.new }
+      client.greeting(true).should == SpecNamespace::Hello.new
       queues[5] << [:unblock, 4]
       4.times { result.pop.should be_true }
       queues[2] << :hello
-      result.pop.should == Hello.new
-      client.greeting(false).should == Hello.new(:greeting => 'Aloha!')
+      result.pop.should == SpecNamespace::Hello.new
+      client.greeting(false).should == SpecNamespace::Hello.new(:greeting => 'Aloha!')
       7.times { queues.shift << :exit }
-      client.greeting(true).should == Hello.new
+      client.greeting(true).should == SpecNamespace::Hello.new
       @server.shutdown
     end
 
@@ -257,7 +255,7 @@ class ThriftNonblockingServerSpec < Spec
 
     it "should allow shutting down in response to a message" do
       client = setup_client
-      client.greeting(true).should == Hello.new
+      client.greeting(true).should == SpecNamespace::Hello.new
       client.shutdown
       @server_thread.join(2).should_not be_nil
     end

Modified: thrift/trunk/lib/rb/spec/processor_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/processor_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/processor_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/processor_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,16 +17,15 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftProcessorSpec < Spec::ExampleGroup
-  include Thrift
+describe 'Processor' do
 
   class ProcessorSpec
     include Thrift::Processor
   end
 
-  describe "Processor" do
+  describe Thrift::Processor do
     before(:each) do
       @processor = ProcessorSpec.new(mock("MockHandler"))
       @prot = mock("MockProtocol")
@@ -41,21 +40,19 @@ class ThriftProcessorSpec < Spec::Exampl
     end
 
     it "should call process_<message> when it receives that message" do
-      @prot.should_receive(:read_message_begin).ordered.and_return ['testMessage', MessageTypes::CALL, 17]
+      @prot.should_receive(:read_message_begin).ordered.and_return ['testMessage', Thrift::MessageTypes::CALL, 17]
       @processor.should_receive(:process_testMessage).with(17, @prot, @prot).ordered
       @processor.process(@prot, @prot).should == true
     end
 
     it "should raise an ApplicationException when the received message cannot be processed" do
-      @prot.should_receive(:read_message_begin).ordered.and_return ['testMessage', MessageTypes::CALL, 4]
-      @prot.should_receive(:skip).with(Types::STRUCT).ordered
+      @prot.should_receive(:read_message_begin).ordered.and_return ['testMessage', Thrift::MessageTypes::CALL, 4]
+      @prot.should_receive(:skip).with(Thrift::Types::STRUCT).ordered
       @prot.should_receive(:read_message_end).ordered
-      @prot.should_receive(:write_message_begin).with('testMessage', MessageTypes::EXCEPTION, 4).ordered
-      ApplicationException.should_receive(:new).with(ApplicationException::UNKNOWN_METHOD, "Unknown function testMessage").and_return do
-        mock(ApplicationException).tee do |e|
-          e.should_receive(:write).with(@prot).ordered
-        end
-      end
+      @prot.should_receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::EXCEPTION, 4).ordered
+      e = mock(Thrift::ApplicationException)
+      e.should_receive(:write).with(@prot).ordered
+      Thrift::ApplicationException.should_receive(:new).with(Thrift::ApplicationException::UNKNOWN_METHOD, "Unknown function testMessage").and_return(e)
       @prot.should_receive(:write_message_end).ordered
       mock_trans(@prot)
       @processor.process(@prot, @prot)
@@ -72,7 +69,7 @@ class ThriftProcessorSpec < Spec::Exampl
     end
 
     it "should write out a reply when asked" do
-      @prot.should_receive(:write_message_begin).with('testMessage', MessageTypes::REPLY, 23).ordered
+      @prot.should_receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::REPLY, 23).ordered
       result = mock("MockResult")
       result.should_receive(:write).with(@prot).ordered
       @prot.should_receive(:write_message_end).ordered

Modified: thrift/trunk/lib/rb/spec/serializer_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/serializer_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/serializer_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/serializer_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,53 +17,51 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 
-class ThriftSerializerSpec < Spec::ExampleGroup
-  include Thrift
-  include SpecNamespace
+describe 'Serializer' do
 
-  describe Serializer do
+  describe Thrift::Serializer do
     it "should serialize structs to binary by default" do
-      serializer = Serializer.new(Thrift::BinaryProtocolAcceleratedFactory.new)
-      data = serializer.serialize(Hello.new(:greeting => "'Ello guv'nor!"))
+      serializer = Thrift::Serializer.new(Thrift::BinaryProtocolAcceleratedFactory.new)
+      data = serializer.serialize(SpecNamespace::Hello.new(:greeting => "'Ello guv'nor!"))
       data.should == "\x0B\x00\x01\x00\x00\x00\x0E'Ello guv'nor!\x00"
     end
 
     it "should serialize structs to the given protocol" do
-      protocol = BaseProtocol.new(mock("transport"))
+      protocol = Thrift::BaseProtocol.new(mock("transport"))
       protocol.should_receive(:write_struct_begin).with("SpecNamespace::Hello")
-      protocol.should_receive(:write_field_begin).with("greeting", Types::STRING, 1)
+      protocol.should_receive(:write_field_begin).with("greeting", Thrift::Types::STRING, 1)
       protocol.should_receive(:write_string).with("Good day")
       protocol.should_receive(:write_field_end)
       protocol.should_receive(:write_field_stop)
       protocol.should_receive(:write_struct_end)
       protocol_factory = mock("ProtocolFactory")
       protocol_factory.stub!(:get_protocol).and_return(protocol)
-      serializer = Serializer.new(protocol_factory)
-      serializer.serialize(Hello.new(:greeting => "Good day"))
+      serializer = Thrift::Serializer.new(protocol_factory)
+      serializer.serialize(SpecNamespace::Hello.new(:greeting => "Good day"))
     end
   end
 
-  describe Deserializer do
+  describe Thrift::Deserializer do
     it "should deserialize structs from binary by default" do
-      deserializer = Deserializer.new
+      deserializer = Thrift::Deserializer.new
       data = "\x0B\x00\x01\x00\x00\x00\x0E'Ello guv'nor!\x00"
-      deserializer.deserialize(Hello.new, data).should == Hello.new(:greeting => "'Ello guv'nor!")
+      deserializer.deserialize(SpecNamespace::Hello.new, data).should == SpecNamespace::Hello.new(:greeting => "'Ello guv'nor!")
     end
 
     it "should deserialize structs from the given protocol" do
-      protocol = BaseProtocol.new(mock("transport"))
+      protocol = Thrift::BaseProtocol.new(mock("transport"))
       protocol.should_receive(:read_struct_begin).and_return("SpecNamespace::Hello")
-      protocol.should_receive(:read_field_begin).and_return(["greeting", Types::STRING, 1],
-                                                            [nil, Types::STOP, 0])
+      protocol.should_receive(:read_field_begin).and_return(["greeting", Thrift::Types::STRING, 1],
+                                                            [nil, Thrift::Types::STOP, 0])
       protocol.should_receive(:read_string).and_return("Good day")
       protocol.should_receive(:read_field_end)
       protocol.should_receive(:read_struct_end)
       protocol_factory = mock("ProtocolFactory")
       protocol_factory.stub!(:get_protocol).and_return(protocol)
-      deserializer = Deserializer.new(protocol_factory)
-      deserializer.deserialize(Hello.new, "").should == Hello.new(:greeting => "Good day")
+      deserializer = Thrift::Deserializer.new(protocol_factory)
+      deserializer.deserialize(SpecNamespace::Hello.new, "").should == SpecNamespace::Hello.new(:greeting => "Good day")
     end
   end
 end

Modified: thrift/trunk/lib/rb/spec/server_socket_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/server_socket_spec.rb?rev=1391280&r1=1391279&r2=1391280&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/server_socket_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/server_socket_spec.rb Fri Sep 28 01:59:04 2012
@@ -17,15 +17,14 @@
 # under the License.
 #
 
-require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
+require 'spec_helper'
 require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
 
-class ThriftServerSocketSpec < Spec::ExampleGroup
-  include Thrift
+describe 'Thrift::ServerSocket' do
 
-  describe ServerSocket do
+  describe Thrift::ServerSocket do
     before(:each) do
-      @socket = ServerSocket.new(1234)
+      @socket = Thrift::ServerSocket.new(1234)
     end
 
     it "should create a handle when calling listen" do
@@ -34,7 +33,7 @@ class ThriftServerSocketSpec < Spec::Exa
     end
 
     it "should accept an optional host argument" do
-      @socket = ServerSocket.new('localhost', 1234)
+      @socket = Thrift::ServerSocket.new('localhost', 1234)
       TCPServer.should_receive(:new).with('localhost', 1234)
       @socket.listen
     end
@@ -46,7 +45,7 @@ class ThriftServerSocketSpec < Spec::Exa
       sock = mock("sock")
       handle.should_receive(:accept).and_return(sock)
       trans = mock("Socket")
-     Socket.should_receive(:new).and_return(trans)
+      Thrift::Socket.should_receive(:new).and_return(trans)
       trans.should_receive(:handle=).with(sock)
       @socket.accept.should == trans
     end