THRIFT-276. rb: Ruby libraries should have one class per file
This monster of a patch moves all the classes into their own files and specs as appropriate. Additionally, it concentrates all the requires into thrift.rb, removing the need to require any other file. (Changes were made to the compiler to reflect this reduced requirement.)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761849 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/protocol_spec.rb b/lib/rb/spec/base_protocol_spec.rb
similarity index 95%
rename from lib/rb/spec/protocol_spec.rb
rename to lib/rb/spec/base_protocol_spec.rb
index 57b64ab..efb16d8 100644
--- a/lib/rb/spec/protocol_spec.rb
+++ b/lib/rb/spec/base_protocol_spec.rb
@@ -19,15 +19,15 @@
require File.dirname(__FILE__) + '/spec_helper'
-class ThriftProtocolSpec < Spec::ExampleGroup
+class ThriftBaseProtocolSpec < Spec::ExampleGroup
include Thrift
before(:each) do
@trans = mock("MockTransport")
- @prot = Protocol.new(@trans)
+ @prot = BaseProtocol.new(@trans)
end
- describe Protocol do
+ describe BaseProtocol do
# most of the methods are stubs, so we can ignore them
it "should make trans accessible" do
@@ -151,10 +151,10 @@
end
end
- describe ProtocolFactory do
+ describe BaseProtocolFactory do
it "should raise NotImplementedError" do
# returning nil since Protocol is just an abstract class
- lambda {ProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
+ lambda {BaseProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
end
end
end
diff --git a/lib/rb/spec/transport_spec.rb b/lib/rb/spec/base_transport_spec.rb
similarity index 94%
rename from lib/rb/spec/transport_spec.rb
rename to lib/rb/spec/base_transport_spec.rb
index 709a93e..7189775 100644
--- a/lib/rb/spec/transport_spec.rb
+++ b/lib/rb/spec/base_transport_spec.rb
@@ -19,7 +19,7 @@
require File.dirname(__FILE__) + '/spec_helper'
-class ThriftTransportSpec < Spec::ExampleGroup
+class ThriftBaseTransportSpec < Spec::ExampleGroup
include Thrift
describe TransportException do
@@ -30,9 +30,9 @@
end
end
- describe Transport do
+ describe BaseTransport do
it "should read the specified size" do
- transport = Transport.new
+ transport = 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,27 +42,27 @@
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|
- Transport.method_defined?(sym).should be_true
+ BaseTransport.method_defined?(sym).should be_true
end
end
it "should alias << to write" do
- Transport.instance_method(:<<).should == Transport.instance_method(:write)
+ BaseTransport.instance_method(:<<).should == BaseTransport.instance_method(:write)
end
end
- describe ServerTransport do
+ describe BaseServerTransport do
it "should stub out its methods" do
[:listen, :accept, :close].each do |sym|
- ServerTransport.method_defined?(sym).should be_true
+ BaseServerTransport.method_defined?(sym).should be_true
end
end
end
- describe TransportFactory do
+ describe BaseTransportFactory do
it "should return the transport it's given" do
transport = mock("Transport")
- TransportFactory.new.get_transport(transport).should eql(transport)
+ BaseTransportFactory.new.get_transport(transport).should eql(transport)
end
end
@@ -250,14 +250,14 @@
end
end
- describe MemoryBuffer do
+ describe MemoryBufferTransport do
before(:each) do
- @buffer = MemoryBuffer.new
+ @buffer = MemoryBufferTransport.new
end
it "should accept a buffer on input and use it directly" do
s = "this is a test"
- @buffer = MemoryBuffer.new(s)
+ @buffer = MemoryBufferTransport.new(s)
@buffer.read(4).should == "this"
s.slice!(-4..-1)
@buffer.read(@buffer.available).should == " is a "
diff --git a/lib/rb/spec/binaryprotocolaccelerated_spec.rb b/lib/rb/spec/binary_protocol_accelerated_spec.rb
similarity index 92%
rename from lib/rb/spec/binaryprotocolaccelerated_spec.rb
rename to lib/rb/spec/binary_protocol_accelerated_spec.rb
index f8f9b90..a834f7c 100644
--- a/lib/rb/spec/binaryprotocolaccelerated_spec.rb
+++ b/lib/rb/spec/binary_protocol_accelerated_spec.rb
@@ -18,8 +18,7 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require 'thrift/protocol/binaryprotocolaccelerated'
-require File.dirname(__FILE__) + '/binaryprotocol_spec_shared'
+require File.dirname(__FILE__) + '/binary_protocol_spec_shared'
require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
class ThriftBinaryProtocolAcceleratedSpec < Spec::ExampleGroup
diff --git a/lib/rb/spec/binaryprotocol_spec.rb b/lib/rb/spec/binary_protocol_spec.rb
similarity index 95%
rename from lib/rb/spec/binaryprotocol_spec.rb
rename to lib/rb/spec/binary_protocol_spec.rb
index 3a0d691..0abccb8 100644
--- a/lib/rb/spec/binaryprotocol_spec.rb
+++ b/lib/rb/spec/binary_protocol_spec.rb
@@ -18,8 +18,7 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require 'thrift/protocol/binaryprotocol'
-require File.dirname(__FILE__) + '/binaryprotocol_spec_shared'
+require File.dirname(__FILE__) + '/binary_protocol_spec_shared'
class ThriftBinaryProtocolSpec < Spec::ExampleGroup
include Thrift
diff --git a/lib/rb/spec/binaryprotocol_spec_shared.rb b/lib/rb/spec/binary_protocol_spec_shared.rb
similarity index 94%
rename from lib/rb/spec/binaryprotocol_spec_shared.rb
rename to lib/rb/spec/binary_protocol_spec_shared.rb
index 18ea8e8..c6608e0 100644
--- a/lib/rb/spec/binaryprotocol_spec_shared.rb
+++ b/lib/rb/spec/binary_protocol_spec_shared.rb
@@ -21,7 +21,7 @@
shared_examples_for 'a binary protocol' do
before(:each) do
- @trans = Thrift::MemoryBuffer.new
+ @trans = Thrift::MemoryBufferTransport.new
@prot = protocol_class.new(@trans)
end
@@ -203,17 +203,18 @@
lambda { @prot.write_string(nil) }.should raise_error
end
- it "should read message header correctly" do
- @trans.write([protocol_class.const_get(:VERSION_1) | Thrift::MessageTypes::CALL, "testMessage".size, "testMessage", 17].pack("NNa11N"))
- @prot.read_message_begin().should == ['testMessage', Thrift::MessageTypes::CALL, 17]
+ it "should write the message header without version when writes are not strict" do
+ @prot = protocol_class.new(@trans, true, false) # no strict write
+ @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 17)
+ @trans.read(1000).should == "\000\000\000\vtestMessage\001\000\000\000\021"
+ end
+
+ it "should write the message header with a version when writes are strict" do
+ @prot = protocol_class.new(@trans) # strict write
+ @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 17)
+ @trans.read(1000).should == "\200\001\000\001\000\000\000\vtestMessage\000\000\000\021"
end
- it "should read the message header without version when writes are not strict" do
- @prot = protocol_class.new(@trans, false, true) # no strict write
- @trans.write("\000\000\000\vtestMessage\001\000\000\000\021")
- @prot.read_message_begin().should == ['testMessage', Thrift::MessageTypes::CALL, 17]
- end
-
# message footer is a noop
it "should read a field header" do
@@ -345,7 +346,7 @@
processor = Srv::Processor.new(SrvHandler.new)
client = Srv::Client.new(clientproto, clientproto)
-
+
# first block
firstblock.call(client)
@@ -371,5 +372,4 @@
Fixtures::COMPACT_PROTOCOL_TEST_STRUCT
end
end
-
end
diff --git a/lib/rb/spec/compact_protocol_spec.rb b/lib/rb/spec/compact_protocol_spec.rb
index 9071fb1..78b1a2a 100644
--- a/lib/rb/spec/compact_protocol_spec.rb
+++ b/lib/rb/spec/compact_protocol_spec.rb
@@ -18,7 +18,6 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require "thrift/protocol/compact_protocol"
describe Thrift::CompactProtocol do
TESTS = {
@@ -36,7 +35,7 @@
TESTS.each_pair do |primitive_type, test_values|
test_values.each do |value|
# puts "testing #{value}" if primitive_type == :i64
- trans = Thrift::MemoryBuffer.new
+ trans = Thrift::MemoryBufferTransport.new
proto = Thrift::CompactProtocol.new(trans)
proto.send(writer(primitive_type), value)
@@ -53,7 +52,7 @@
thrift_type = Thrift::Types.const_get(final_primitive_type.to_s.upcase)
# puts primitive_type
test_values.each do |value|
- trans = Thrift::MemoryBuffer.new
+ trans = Thrift::MemoryBufferTransport.new
proto = Thrift::CompactProtocol.new(trans)
proto.write_field_begin(nil, thrift_type, 15)
@@ -72,7 +71,7 @@
end
it "should encode and decode a monster struct correctly" do
- trans = Thrift::MemoryBuffer.new
+ trans = Thrift::MemoryBufferTransport.new
proto = Thrift::CompactProtocol.new(trans)
struct = CompactProtoTestStruct.new
@@ -96,10 +95,10 @@
end
it "should make method calls correctly" do
- client_out_trans = Thrift::MemoryBuffer.new
+ client_out_trans = Thrift::MemoryBufferTransport.new
client_out_proto = Thrift::CompactProtocol.new(client_out_trans)
- client_in_trans = Thrift::MemoryBuffer.new
+ client_in_trans = Thrift::MemoryBufferTransport.new
client_in_proto = Thrift::CompactProtocol.new(client_in_trans)
processor = Srv::Processor.new(JankyHandler.new)
diff --git a/lib/rb/spec/httpclient_spec.rb b/lib/rb/spec/http_client_spec.rb
similarity index 89%
rename from lib/rb/spec/httpclient_spec.rb
rename to lib/rb/spec/http_client_spec.rb
index d48073f..94526de 100644
--- a/lib/rb/spec/httpclient_spec.rb
+++ b/lib/rb/spec/http_client_spec.rb
@@ -18,14 +18,13 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require 'thrift/transport/httpclient'
-class ThriftHTTPClientSpec < Spec::ExampleGroup
+class ThriftHTTPClientTransportSpec < Spec::ExampleGroup
include Thrift
- describe HTTPClient do
+ describe HTTPClientTransport do
before(:each) do
- @client = HTTPClient.new("http://my.domain.com/path/to/service")
+ @client = HTTPClientTransport.new("http://my.domain.com/path/to/service")
end
it "should always be open" do
diff --git a/lib/rb/spec/httpserver_spec.rb b/lib/rb/spec/mongrel_http_server_spec.rb
similarity index 92%
rename from lib/rb/spec/httpserver_spec.rb
rename to lib/rb/spec/mongrel_http_server_spec.rb
index e03f1c1..c994491 100644
--- a/lib/rb/spec/httpserver_spec.rb
+++ b/lib/rb/spec/mongrel_http_server_spec.rb
@@ -18,14 +18,14 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require 'thrift/server/httpserver'
+require 'thrift/server/mongrel_http_server'
class ThriftHTTPServerSpec < Spec::ExampleGroup
include Thrift
- Handler = SimpleMongrelHTTPServer::Handler
+ Handler = MongrelHTTPServer::Handler
- describe SimpleMongrelHTTPServer do
+ describe MongrelHTTPServer do
it "should have appropriate defaults" do
mock_factory = mock("BinaryProtocolFactory")
mock_proc = mock("Processor")
@@ -37,7 +37,7 @@
mock.should_receive(:register).with("/", handler)
end
end
- SimpleMongrelHTTPServer.new(mock_proc)
+ MongrelHTTPServer.new(mock_proc)
end
it "should understand :ip, :port, :path, and :protocol_factory" do
@@ -50,7 +50,7 @@
mock.should_receive(:register).with("/foo", handler)
end
end
- SimpleMongrelHTTPServer.new(mock_proc, :ip => "1.2.3.4", :port => 1234, :path => "foo",
+ MongrelHTTPServer.new(mock_proc, :ip => "1.2.3.4", :port => 1234, :path => "foo",
:protocol_factory => mock_factory)
end
@@ -67,11 +67,11 @@
end
end
end
- SimpleMongrelHTTPServer.new(nil).serve
+ MongrelHTTPServer.new(nil).serve
end
end
- describe SimpleMongrelHTTPServer::Handler do
+ describe MongrelHTTPServer::Handler do
before(:each) do
@processor = mock("Processor")
@factory = mock("ProtocolFactory")
diff --git a/lib/rb/spec/nonblockingserver_spec.rb b/lib/rb/spec/nonblocking_server_spec.rb
similarity index 97%
rename from lib/rb/spec/nonblockingserver_spec.rb
rename to lib/rb/spec/nonblocking_server_spec.rb
index 02666db..22c9280 100644
--- a/lib/rb/spec/nonblockingserver_spec.rb
+++ b/lib/rb/spec/nonblocking_server_spec.rb
@@ -18,7 +18,6 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require 'thrift/server/nonblockingserver'
require File.dirname(__FILE__) + '/gen-rb/NonblockingService'
class ThriftNonblockingServerSpec < Spec::ExampleGroup
@@ -57,7 +56,7 @@
end
end
- class SpecTransport < Transport
+ class SpecTransport < BaseTransport
def initialize(transport, queue)
@transport = transport
@queue = queue
@@ -110,10 +109,10 @@
processor = NonblockingService::Processor.new(handler)
queue = Queue.new
@transport = SpecServerSocket.new('localhost', @port, queue)
- transportFactory = FramedTransportFactory.new
+ transport_factory = FramedTransportFactory.new
logger = Logger.new(STDERR)
logger.level = Logger::WARN
- @server = NonblockingServer.new(processor, @transport, transportFactory, nil, 5, logger)
+ @server = NonblockingServer.new(processor, @transport, transport_factory, nil, 5, logger)
handler.server = @server
@server_thread = Thread.new(Thread.current) do |master_thread|
begin
diff --git a/lib/rb/spec/serializer_spec.rb b/lib/rb/spec/serializer_spec.rb
index 3411c53..db52133 100644
--- a/lib/rb/spec/serializer_spec.rb
+++ b/lib/rb/spec/serializer_spec.rb
@@ -18,7 +18,6 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require 'thrift/serializer'
require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
class ThriftSerializerSpec < Spec::ExampleGroup
@@ -33,16 +32,16 @@
end
it "should serialize structs to the given protocol" do
- protocol = Protocol.new(mock("transport"))
+ protocol = 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_string).with("Good day")
protocol.should_receive(:write_field_end)
protocol.should_receive(:write_field_stop)
protocol.should_receive(:write_struct_end)
- protocolFactory = mock("ProtocolFactory")
- protocolFactory.stub!(:get_protocol).and_return(protocol)
- serializer = Serializer.new(protocolFactory)
+ protocol_factory = mock("ProtocolFactory")
+ protocol_factory.stub!(:get_protocol).and_return(protocol)
+ serializer = Serializer.new(protocol_factory)
serializer.serialize(Hello.new(:greeting => "Good day"))
end
end
@@ -55,16 +54,16 @@
end
it "should deserialize structs from the given protocol" do
- protocol = Protocol.new(mock("transport"))
+ protocol = 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_string).and_return("Good day")
protocol.should_receive(:read_field_end)
protocol.should_receive(:read_struct_end)
- protocolFactory = mock("ProtocolFactory")
- protocolFactory.stub!(:get_protocol).and_return(protocol)
- deserializer = Deserializer.new(protocolFactory)
+ 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")
end
end
diff --git a/lib/rb/spec/server_socket_spec.rb b/lib/rb/spec/server_socket_spec.rb
new file mode 100644
index 0000000..fce5013
--- /dev/null
+++ b/lib/rb/spec/server_socket_spec.rb
@@ -0,0 +1,80 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require File.dirname(__FILE__) + '/spec_helper'
+require File.dirname(__FILE__) + "/socket_spec_shared"
+
+class ThriftServerSocketSpec < Spec::ExampleGroup
+ include Thrift
+
+ describe ServerSocket do
+ before(:each) do
+ @socket = ServerSocket.new(1234)
+ end
+
+ it "should create a handle when calling listen" do
+ TCPServer.should_receive(:new).with(nil, 1234)
+ @socket.listen
+ end
+
+ it "should accept an optional host argument" do
+ @socket = ServerSocket.new('localhost', 1234)
+ TCPServer.should_receive(:new).with('localhost', 1234)
+ @socket.listen
+ end
+
+ it "should create a Thrift::Socket to wrap accepted sockets" do
+ handle = mock("TCPServer")
+ TCPServer.should_receive(:new).with(nil, 1234).and_return(handle)
+ @socket.listen
+ sock = mock("sock")
+ handle.should_receive(:accept).and_return(sock)
+ trans = mock("Socket")
+ Socket.should_receive(:new).and_return(trans)
+ trans.should_receive(:handle=).with(sock)
+ @socket.accept.should == trans
+ end
+
+ it "should close the handle when closed" do
+ handle = mock("TCPServer", :closed? => false)
+ TCPServer.should_receive(:new).with(nil, 1234).and_return(handle)
+ @socket.listen
+ handle.should_receive(:close)
+ @socket.close
+ end
+
+ it "should return nil when accepting if there is no handle" do
+ @socket.accept.should be_nil
+ end
+
+ it "should return true for closed? when appropriate" do
+ handle = mock("TCPServer", :closed? => false)
+ TCPServer.stub!(:new).and_return(handle)
+ @socket.listen
+ @socket.should_not be_closed
+ handle.stub!(:close)
+ @socket.close
+ @socket.should be_closed
+ @socket.listen
+ @socket.should_not be_closed
+ handle.stub!(:closed?).and_return(true)
+ @socket.should be_closed
+ end
+ end
+end
diff --git a/lib/rb/spec/server_spec.rb b/lib/rb/spec/server_spec.rb
index 7c6ebd4..ffe9bff 100644
--- a/lib/rb/spec/server_spec.rb
+++ b/lib/rb/spec/server_spec.rb
@@ -22,11 +22,11 @@
class ThriftServerSpec < Spec::ExampleGroup
include Thrift
- describe Server do
- it "should default to TransportFactory and BinaryProtocolFactory when not specified" do
- server = Server.new(mock("Processor"), mock("ServerTransport"))
- server.instance_variable_get(:'@transportFactory').should be_an_instance_of(TransportFactory)
- server.instance_variable_get(:'@protocolFactory').should be_an_instance_of(BinaryProtocolFactory)
+ describe BaseServer do
+ it "should default to BaseTransportFactory and BinaryProtocolFactory when not specified" do
+ server = BaseServer.new(mock("Processor"), mock("BaseServerTransport"))
+ server.instance_variable_get(:'@transport_factory').should be_an_instance_of(BaseTransportFactory)
+ server.instance_variable_get(:'@protocol_factory').should be_an_instance_of(BinaryProtocolFactory)
end
# serve is a noop, so can't test that
@@ -36,8 +36,8 @@
before(:each) do
@processor = mock("Processor")
@serverTrans = mock("ServerTransport")
- @trans = mock("Transport")
- @prot = mock("Protocol")
+ @trans = mock("BaseTransport")
+ @prot = mock("BaseProtocol")
@client = mock("Client")
@server = server_type.new(@processor, @serverTrans, @trans, @prot)
end
diff --git a/lib/rb/spec/socket_spec.rb b/lib/rb/spec/socket_spec.rb
index 30b4648..dd8b0f9 100644
--- a/lib/rb/spec/socket_spec.rb
+++ b/lib/rb/spec/socket_spec.rb
@@ -58,59 +58,4 @@
Socket.new('localhost', 8080, 5).timeout.should == 5
end
end
-
- describe ServerSocket do
- before(:each) do
- @socket = ServerSocket.new(1234)
- end
-
- it "should create a handle when calling listen" do
- TCPServer.should_receive(:new).with(nil, 1234)
- @socket.listen
- end
-
- it "should accept an optional host argument" do
- @socket = ServerSocket.new('localhost', 1234)
- TCPServer.should_receive(:new).with('localhost', 1234)
- @socket.listen
- end
-
- it "should create a Thrift::Socket to wrap accepted sockets" do
- handle = mock("TCPServer")
- TCPServer.should_receive(:new).with(nil, 1234).and_return(handle)
- @socket.listen
- sock = mock("sock")
- handle.should_receive(:accept).and_return(sock)
- trans = mock("Socket")
- Socket.should_receive(:new).and_return(trans)
- trans.should_receive(:handle=).with(sock)
- @socket.accept.should == trans
- end
-
- it "should close the handle when closed" do
- handle = mock("TCPServer", :closed? => false)
- TCPServer.should_receive(:new).with(nil, 1234).and_return(handle)
- @socket.listen
- handle.should_receive(:close)
- @socket.close
- end
-
- it "should return nil when accepting if there is no handle" do
- @socket.accept.should be_nil
- end
-
- it "should return true for closed? when appropriate" do
- handle = mock("TCPServer", :closed? => false)
- TCPServer.stub!(:new).and_return(handle)
- @socket.listen
- @socket.should_not be_closed
- handle.stub!(:close)
- @socket.close
- @socket.should be_closed
- @socket.listen
- @socket.should_not be_closed
- handle.stub!(:closed?).and_return(true)
- @socket.should be_closed
- end
- end
end
diff --git a/lib/rb/spec/spec_helper.rb b/lib/rb/spec/spec_helper.rb
index d099491..41bf631 100644
--- a/lib/rb/spec/spec_helper.rb
+++ b/lib/rb/spec/spec_helper.rb
@@ -24,7 +24,7 @@
$:.unshift File.join(File.dirname(__FILE__), *%w[.. ext])
-# pretend we already loaded fastthread, otherwise the nonblockingserver_spec
+# pretend we already loaded fastthread, otherwise the nonblocking_server_spec
# will get screwed up
# $" << 'fastthread.bundle'
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index 69826e7..bfcf0ea 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -20,8 +20,6 @@
require File.dirname(__FILE__) + '/spec_helper'
require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
-# require "binaryprotocolaccelerated"
-
class ThriftStructSpec < Spec::ExampleGroup
include Thrift
include SpecNamespace
@@ -67,7 +65,7 @@
it "should read itself off the wire" do
struct = Foo.new
- prot = Protocol.new(mock("transport"))
+ prot = BaseProtocol.new(mock("transport"))
prot.should_receive(:read_struct_begin).twice
prot.should_receive(:read_struct_end).twice
prot.should_receive(:read_field_begin).and_return(
@@ -113,7 +111,7 @@
it "should skip unexpected fields in structs and use default values" do
struct = Foo.new
- prot = Protocol.new(mock("transport"))
+ prot = BaseProtocol.new(mock("transport"))
prot.should_receive(:read_struct_begin)
prot.should_receive(:read_struct_end)
prot.should_receive(:read_field_begin).and_return(
@@ -143,7 +141,7 @@
end
it "should write itself to the wire" do
- prot = Protocol.new(mock("transport")) #mock("Protocol")
+ prot = BaseProtocol.new(mock("transport")) #mock("Protocol")
prot.should_receive(:write_struct_begin).with("SpecNamespace::Foo")
prot.should_receive(:write_struct_begin).with("SpecNamespace::Hello")
prot.should_receive(:write_struct_end).twice
@@ -218,7 +216,7 @@
e.message.should == "something happened"
e.code.should == 1
# ensure it gets serialized properly, this is the really important part
- prot = Protocol.new(mock("trans"))
+ prot = BaseProtocol.new(mock("trans"))
prot.should_receive(:write_struct_begin).with("SpecNamespace::Xception")
prot.should_receive(:write_struct_end)
prot.should_receive(:write_field_begin).with('message', Types::STRING, 1)#, "something happened")
@@ -238,7 +236,7 @@
rescue Thrift::Exception => e
e.message.should == "something happened"
e.code.should == 5
- prot = Protocol.new(mock("trans"))
+ prot = BaseProtocol.new(mock("trans"))
prot.should_receive(:write_struct_begin).with("SpecNamespace::Xception")
prot.should_receive(:write_struct_end)
prot.should_receive(:write_field_begin).with('message', Types::STRING, 1)
diff --git a/lib/rb/spec/unixsocket_spec.rb b/lib/rb/spec/unix_socket_spec.rb
similarity index 98%
rename from lib/rb/spec/unixsocket_spec.rb
rename to lib/rb/spec/unix_socket_spec.rb
index 574e2bb..df239d7 100644
--- a/lib/rb/spec/unixsocket_spec.rb
+++ b/lib/rb/spec/unix_socket_spec.rb
@@ -18,7 +18,6 @@
#
require File.dirname(__FILE__) + '/spec_helper'
-require 'thrift/transport/unixsocket'
require File.dirname(__FILE__) + "/socket_spec_shared"
class ThriftUNIXSocketSpec < Spec::ExampleGroup