THRIFT-4342: update ruby tests to use rspec 3, updated all dependencies for ruby
Client: rb
diff --git a/lib/rb/spec/base_protocol_spec.rb b/lib/rb/spec/base_protocol_spec.rb
index d31e811..eca936b 100644
--- a/lib/rb/spec/base_protocol_spec.rb
+++ b/lib/rb/spec/base_protocol_spec.rb
@@ -22,7 +22,7 @@
describe 'BaseProtocol' do
before(:each) do
- @trans = mock("MockTransport")
+ @trans = double("MockTransport")
@prot = Thrift::BaseProtocol.new(@trans)
end
@@ -30,38 +30,38 @@
# most of the methods are stubs, so we can ignore them
it "should provide a reasonable to_s" do
- @trans.should_receive(:to_s).once.and_return("trans")
- @prot.to_s.should == "trans"
+ expect(@trans).to receive(:to_s).once.and_return("trans")
+ expect(@prot.to_s).to eq("trans")
end
it "should make trans accessible" do
- @prot.trans.should eql(@trans)
+ expect(@prot.trans).to eql(@trans)
end
it 'should write out a field nicely (deprecated write_field signature)' do
- @prot.should_receive(:write_field_begin).with('field', 'type', 'fid').ordered
- @prot.should_receive(:write_type).with({:name => 'field', :type => 'type'}, 'value').ordered
- @prot.should_receive(:write_field_end).ordered
+ expect(@prot).to receive(:write_field_begin).with('field', 'type', 'fid').ordered
+ expect(@prot).to receive(:write_type).with({:name => 'field', :type => 'type'}, 'value').ordered
+ expect(@prot).to receive(:write_field_end).ordered
@prot.write_field('field', 'type', 'fid', 'value')
end
it 'should write out a field nicely' do
- @prot.should_receive(:write_field_begin).with('field', 'type', 'fid').ordered
- @prot.should_receive(:write_type).with({:name => 'field', :type => 'type', :binary => false}, 'value').ordered
- @prot.should_receive(:write_field_end).ordered
+ expect(@prot).to receive(:write_field_begin).with('field', 'type', 'fid').ordered
+ expect(@prot).to receive(:write_type).with({:name => 'field', :type => 'type', :binary => false}, 'value').ordered
+ expect(@prot).to receive(:write_field_end).ordered
@prot.write_field({:name => 'field', :type => 'type', :binary => false}, 'fid', 'value')
end
it 'should write out the different types (deprecated write_type signature)' do
- @prot.should_receive(:write_bool).with('bool').ordered
- @prot.should_receive(:write_byte).with('byte').ordered
- @prot.should_receive(:write_double).with('double').ordered
- @prot.should_receive(:write_i16).with('i16').ordered
- @prot.should_receive(:write_i32).with('i32').ordered
- @prot.should_receive(:write_i64).with('i64').ordered
- @prot.should_receive(:write_string).with('string').ordered
- struct = mock('Struct')
- struct.should_receive(:write).with(@prot).ordered
+ expect(@prot).to receive(:write_bool).with('bool').ordered
+ expect(@prot).to receive(:write_byte).with('byte').ordered
+ expect(@prot).to receive(:write_double).with('double').ordered
+ expect(@prot).to receive(:write_i16).with('i16').ordered
+ expect(@prot).to receive(:write_i32).with('i32').ordered
+ expect(@prot).to receive(:write_i64).with('i64').ordered
+ expect(@prot).to receive(:write_string).with('string').ordered
+ struct = double('Struct')
+ expect(struct).to receive(:write).with(@prot).ordered
@prot.write_type(Thrift::Types::BOOL, 'bool')
@prot.write_type(Thrift::Types::BYTE, 'byte')
@prot.write_type(Thrift::Types::DOUBLE, 'double')
@@ -77,16 +77,16 @@
end
it 'should write out the different types' do
- @prot.should_receive(:write_bool).with('bool').ordered
- @prot.should_receive(:write_byte).with('byte').ordered
- @prot.should_receive(:write_double).with('double').ordered
- @prot.should_receive(:write_i16).with('i16').ordered
- @prot.should_receive(:write_i32).with('i32').ordered
- @prot.should_receive(:write_i64).with('i64').ordered
- @prot.should_receive(:write_string).with('string').ordered
- @prot.should_receive(:write_binary).with('binary').ordered
- struct = mock('Struct')
- struct.should_receive(:write).with(@prot).ordered
+ expect(@prot).to receive(:write_bool).with('bool').ordered
+ expect(@prot).to receive(:write_byte).with('byte').ordered
+ expect(@prot).to receive(:write_double).with('double').ordered
+ expect(@prot).to receive(:write_i16).with('i16').ordered
+ expect(@prot).to receive(:write_i32).with('i32').ordered
+ expect(@prot).to receive(:write_i64).with('i64').ordered
+ expect(@prot).to receive(:write_string).with('string').ordered
+ expect(@prot).to receive(:write_binary).with('binary').ordered
+ struct = double('Struct')
+ expect(struct).to receive(:write).with(@prot).ordered
@prot.write_type({:type => Thrift::Types::BOOL}, 'bool')
@prot.write_type({:type => Thrift::Types::BYTE}, 'byte')
@prot.write_type({:type => Thrift::Types::DOUBLE}, 'double')
@@ -103,13 +103,13 @@
end
it 'should read the different types (deprecated read_type signature)' do
- @prot.should_receive(:read_bool).ordered
- @prot.should_receive(:read_byte).ordered
- @prot.should_receive(:read_i16).ordered
- @prot.should_receive(:read_i32).ordered
- @prot.should_receive(:read_i64).ordered
- @prot.should_receive(:read_double).ordered
- @prot.should_receive(:read_string).ordered
+ expect(@prot).to receive(:read_bool).ordered
+ expect(@prot).to receive(:read_byte).ordered
+ expect(@prot).to receive(:read_i16).ordered
+ expect(@prot).to receive(:read_i32).ordered
+ expect(@prot).to receive(:read_i64).ordered
+ expect(@prot).to receive(:read_double).ordered
+ expect(@prot).to receive(:read_string).ordered
@prot.read_type(Thrift::Types::BOOL)
@prot.read_type(Thrift::Types::BYTE)
@prot.read_type(Thrift::Types::I16)
@@ -125,14 +125,14 @@
end
it 'should read the different types' do
- @prot.should_receive(:read_bool).ordered
- @prot.should_receive(:read_byte).ordered
- @prot.should_receive(:read_i16).ordered
- @prot.should_receive(:read_i32).ordered
- @prot.should_receive(:read_i64).ordered
- @prot.should_receive(:read_double).ordered
- @prot.should_receive(:read_string).ordered
- @prot.should_receive(:read_binary).ordered
+ expect(@prot).to receive(:read_bool).ordered
+ expect(@prot).to receive(:read_byte).ordered
+ expect(@prot).to receive(:read_i16).ordered
+ expect(@prot).to receive(:read_i32).ordered
+ expect(@prot).to receive(:read_i64).ordered
+ expect(@prot).to receive(:read_double).ordered
+ expect(@prot).to receive(:read_string).ordered
+ expect(@prot).to receive(:read_binary).ordered
@prot.read_type({:type => Thrift::Types::BOOL})
@prot.read_type({:type => Thrift::Types::BYTE})
@prot.read_type({:type => Thrift::Types::I16})
@@ -149,13 +149,13 @@
end
it "should skip the basic types" do
- @prot.should_receive(:read_bool).ordered
- @prot.should_receive(:read_byte).ordered
- @prot.should_receive(:read_i16).ordered
- @prot.should_receive(:read_i32).ordered
- @prot.should_receive(:read_i64).ordered
- @prot.should_receive(:read_double).ordered
- @prot.should_receive(:read_string).ordered
+ expect(@prot).to receive(:read_bool).ordered
+ expect(@prot).to receive(:read_byte).ordered
+ expect(@prot).to receive(:read_i16).ordered
+ expect(@prot).to receive(:read_i32).ordered
+ expect(@prot).to receive(:read_i64).ordered
+ expect(@prot).to receive(:read_double).ordered
+ expect(@prot).to receive(:read_string).ordered
@prot.skip(Thrift::Types::BOOL)
@prot.skip(Thrift::Types::BYTE)
@prot.skip(Thrift::Types::I16)
@@ -168,47 +168,47 @@
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(
+ expect(@prot).to receive(:read_struct_begin).ordered
+ expect(@prot).to receive(:read_field_begin).exactly(4).times.and_return(
['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([Thrift::Types::STRING, Thrift::Types::STRING, 1])
+ expect(@prot).to receive(:read_field_end).exactly(3).times
+ expect(@prot).to receive(:read_string).exactly(3).times
+ expect(@prot).to receive(:read_i32).ordered
+ expect(@prot).to 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
+ expect(@prot).to receive(:read_map_end).ordered
+ expect(@prot).to receive(:read_struct_end).ordered
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([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, Thrift::Types::STOP, nil]);
- @prot.should_receive(:read_struct_end).ordered
- @prot.should_receive(:read_map_end).ordered
+ expect(@prot).to receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRUCT, 1])
+ expect(@prot).to receive(:read_string).ordered
+ expect(@prot).to receive(:read_struct_begin).ordered.and_return(["some_struct"])
+ expect(@prot).to receive(:read_field_begin).ordered.and_return([nil, Thrift::Types::STOP, nil]);
+ expect(@prot).to receive(:read_struct_end).ordered
+ expect(@prot).to receive(:read_map_end).ordered
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([Thrift::Types::I64, 9])
- @prot.should_receive(:read_i64).ordered.exactly(9).times
- @prot.should_receive(:read_set_end)
+ expect(@prot).to receive(:read_set_begin).ordered.and_return([Thrift::Types::I64, 9])
+ expect(@prot).to receive(:read_i64).ordered.exactly(9).times
+ expect(@prot).to receive(:read_set_end)
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([Thrift::Types::DOUBLE, 11])
- @prot.should_receive(:read_double).ordered.exactly(11).times
- @prot.should_receive(:read_list_end)
+ expect(@prot).to receive(:read_list_begin).ordered.and_return([Thrift::Types::DOUBLE, 11])
+ expect(@prot).to receive(:read_double).ordered.exactly(11).times
+ expect(@prot).to receive(:read_list_end)
real_skip.call(Thrift::Types::LIST)
end
end
@@ -216,11 +216,11 @@
describe Thrift::BaseProtocolFactory do
it "should raise NotImplementedError" do
# returning nil since Protocol is just an abstract class
- lambda {Thrift::BaseProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
+ expect {Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport"))}.to raise_error(NotImplementedError)
end
it "should provide a reasonable to_s" do
- Thrift::BaseProtocolFactory.new.to_s.should == "base"
+ expect(Thrift::BaseProtocolFactory.new.to_s).to eq("base")
end
end
end