THRIFT-4342: update ruby tests to use rspec 3, updated all dependencies for ruby
Client: rb
diff --git a/lib/rb/spec/exception_spec.rb b/lib/rb/spec/exception_spec.rb
index d1da621..379ae69 100644
--- a/lib/rb/spec/exception_spec.rb
+++ b/lib/rb/spec/exception_spec.rb
@@ -24,107 +24,107 @@
describe Thrift::Exception do
it "should have an accessible message" do
e = Thrift::Exception.new("test message")
- e.message.should == "test message"
+ expect(e.message).to eq("test message")
end
end
describe Thrift::ApplicationException do
it "should inherit from Thrift::Exception" do
- Thrift::ApplicationException.superclass.should == Thrift::Exception
+ expect(Thrift::ApplicationException.superclass).to eq(Thrift::Exception)
end
it "should have an accessible type and message" do
e = Thrift::ApplicationException.new
- e.type.should == Thrift::ApplicationException::UNKNOWN
- e.message.should be_nil
+ expect(e.type).to eq(Thrift::ApplicationException::UNKNOWN)
+ expect(e.message).to be_nil
e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
- e.type.should == Thrift::ApplicationException::UNKNOWN_METHOD
- e.message.should == "test message"
+ expect(e.type).to eq(Thrift::ApplicationException::UNKNOWN_METHOD)
+ expect(e.message).to eq("test message")
end
it "should read a struct off of a protocol" do
- prot = mock("MockProtocol")
- prot.should_receive(:read_struct_begin).ordered
- prot.should_receive(:read_field_begin).exactly(3).times.and_return(
+ prot = double("MockProtocol")
+ expect(prot).to receive(:read_struct_begin).ordered
+ expect(prot).to receive(:read_field_begin).exactly(3).times.and_return(
["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 Thrift::ApplicationException::BAD_SEQUENCE_ID
- prot.should_receive(:read_field_end).exactly(2).times
- prot.should_receive(:read_struct_end).ordered
+ expect(prot).to receive(:read_string).ordered.and_return "test message"
+ expect(prot).to receive(:read_i32).ordered.and_return Thrift::ApplicationException::BAD_SEQUENCE_ID
+ expect(prot).to receive(:read_field_end).exactly(2).times
+ expect(prot).to receive(:read_struct_end).ordered
e = Thrift::ApplicationException.new
e.read(prot)
- e.message.should == "test message"
- e.type.should == Thrift::ApplicationException::BAD_SEQUENCE_ID
+ expect(e.message).to eq("test message")
+ expect(e.type).to eq(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(
+ prot = double("MockProtocol")
+ expect(prot).to receive(:read_struct_begin).ordered
+ expect(prot).to receive(:read_field_begin).exactly(5).times.and_return(
["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 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
+ expect(prot).to receive(:read_i32).and_return Thrift::ApplicationException::INVALID_MESSAGE_TYPE
+ expect(prot).to receive(:skip).with(Thrift::Types::STRING).twice
+ expect(prot).to receive(:skip).with(Thrift::Types::MAP)
+ expect(prot).to receive(:read_field_end).exactly(4).times
+ expect(prot).to receive(:read_struct_end).ordered
e = Thrift::ApplicationException.new
e.read(prot)
- e.message.should be_nil
- e.type.should == Thrift::ApplicationException::INVALID_MESSAGE_TYPE
+ expect(e.message).to be_nil
+ expect(e.type).to eq(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", Thrift::Types::STRING, 1).ordered
- prot.should_receive(:write_string).with("test message").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
+ prot = double("MockProtocol")
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
+ expect(prot).to receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
+ expect(prot).to receive(:write_string).with("test message").ordered
+ expect(prot).to receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
+ expect(prot).to receive(:write_i32).with(Thrift::ApplicationException::UNKNOWN_METHOD).ordered
+ expect(prot).to receive(:write_field_end).twice
+ expect(prot).to receive(:write_field_stop).ordered
+ expect(prot).to receive(:write_struct_end).ordered
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", 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
+ prot = double("MockProtocol")
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
+ expect(prot).to receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
+ expect(prot).to receive(:write_string).with("test message").ordered
+ expect(prot).to receive(:write_field_end).ordered
+ expect(prot).to receive(:write_field_stop).ordered
+ expect(prot).to receive(:write_struct_end).ordered
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", 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
+ prot = double("MockProtocol")
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
+ expect(prot).to receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
+ expect(prot).to receive(:write_i32).with(Thrift::ApplicationException::BAD_SEQUENCE_ID).ordered
+ expect(prot).to receive(:write_field_end).ordered
+ expect(prot).to receive(:write_field_stop).ordered
+ expect(prot).to receive(:write_struct_end).ordered
e = Thrift::ApplicationException.new(Thrift::ApplicationException::BAD_SEQUENCE_ID)
e.write(prot)
- prot = mock("MockProtocol")
- prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
- prot.should_receive(:write_field_stop).ordered
- prot.should_receive(:write_struct_end).ordered
+ prot = double("MockProtocol")
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
+ expect(prot).to receive(:write_field_stop).ordered
+ expect(prot).to receive(:write_struct_end).ordered
e = Thrift::ApplicationException.new(nil)
e.write(prot)
@@ -134,8 +134,8 @@
describe Thrift::ProtocolException do
it "should have an accessible type" do
prot = Thrift::ProtocolException.new(Thrift::ProtocolException::SIZE_LIMIT, "message")
- prot.type.should == Thrift::ProtocolException::SIZE_LIMIT
- prot.message.should == "message"
+ expect(prot.type).to eq(Thrift::ProtocolException::SIZE_LIMIT)
+ expect(prot.message).to eq("message")
end
end
end