Thrift-1644:Upgrade RSpec to 2.11.x and refactor specs as needed
Client: rb
Patch: Nathan Beyer
Upgrading to rspec2.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1391280 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/serializer_spec.rb b/lib/rb/spec/serializer_spec.rb
index 2ecb85b..599b454 100644
--- a/lib/rb/spec/serializer_spec.rb
+++ b/lib/rb/spec/serializer_spec.rb
@@ -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