THRIFT-4342: update ruby tests to use rspec 3, updated all dependencies for ruby
Client: rb
diff --git a/lib/rb/spec/union_spec.rb b/lib/rb/spec/union_spec.rb
index 6ad3194..0ce6306 100644
--- a/lib/rb/spec/union_spec.rb
+++ b/lib/rb/spec/union_spec.rb
@@ -24,85 +24,85 @@
describe Thrift::Union do
it "should return nil value in unset union" do
union = SpecNamespace::My_union.new
- union.get_set_field.should == nil
- union.get_value.should == nil
+ expect(union.get_set_field).to eq(nil)
+ expect(union.get_value).to eq(nil)
end
it "should set a field and be accessible through get_value and the named field accessor" do
union = SpecNamespace::My_union.new
union.integer32 = 25
- union.get_set_field.should == :integer32
- union.get_value.should == 25
- union.integer32.should == 25
+ expect(union.get_set_field).to eq(:integer32)
+ expect(union.get_value).to eq(25)
+ expect(union.integer32).to eq(25)
end
it "should work correctly when instantiated with static field constructors" do
union = SpecNamespace::My_union.integer32(5)
- union.get_set_field.should == :integer32
- union.integer32.should == 5
+ expect(union.get_set_field).to eq(:integer32)
+ expect(union.integer32).to eq(5)
end
it "should raise for wrong set field" do
union = SpecNamespace::My_union.new
union.integer32 = 25
- lambda { union.some_characters }.should raise_error(RuntimeError, "some_characters is not union's set field.")
+ expect { union.some_characters }.to raise_error(RuntimeError, "some_characters is not union's set field.")
end
it "should raise for wrong set field when hash initialized and type checking is off" do
Thrift.type_checking = false
union = SpecNamespace::My_union.new({incorrect_field: :incorrect})
example = lambda { Thrift::Serializer.new.serialize(union) }
- example.should raise_error(RuntimeError, "set_field is not valid for this union!")
+ expect(example).to raise_error(RuntimeError, "set_field is not valid for this union!")
end
it "should not be equal to nil" do
union = SpecNamespace::My_union.new
- union.should_not == nil
+ expect(union).not_to eq(nil)
end
it "should not be equal with an empty String" do
union = SpecNamespace::My_union.new
- union.should_not == ''
+ expect(union).not_to eq('')
end
it "should not equate two different unions, i32 vs. string" do
union = SpecNamespace::My_union.new(:integer32, 25)
other_union = SpecNamespace::My_union.new(:some_characters, "blah!")
- union.should_not == other_union
+ expect(union).not_to eq(other_union)
end
it "should properly reset setfield and setvalue" do
union = SpecNamespace::My_union.new(:integer32, 25)
- union.get_set_field.should == :integer32
+ expect(union.get_set_field).to eq(:integer32)
union.some_characters = "blah!"
- union.get_set_field.should == :some_characters
- union.get_value.should == "blah!"
- lambda { union.integer32 }.should raise_error(RuntimeError, "integer32 is not union's set field.")
+ expect(union.get_set_field).to eq(:some_characters)
+ expect(union.get_value).to eq("blah!")
+ expect { union.integer32 }.to raise_error(RuntimeError, "integer32 is not union's set field.")
end
it "should not equate two different unions with different values" do
union = SpecNamespace::My_union.new(:integer32, 25)
other_union = SpecNamespace::My_union.new(:integer32, 400)
- union.should_not == other_union
+ expect(union).not_to eq(other_union)
end
it "should not equate two different unions with different fields" do
union = SpecNamespace::My_union.new(:integer32, 25)
other_union = SpecNamespace::My_union.new(:other_i32, 25)
- union.should_not == other_union
+ expect(union).not_to eq(other_union)
end
it "should inspect properly" do
union = SpecNamespace::My_union.new(:integer32, 25)
- union.inspect.should == "<SpecNamespace::My_union integer32: 25>"
+ expect(union.inspect).to eq("<SpecNamespace::My_union integer32: 25>")
end
it "should not allow setting with instance_variable_set" do
union = SpecNamespace::My_union.new(:integer32, 27)
union.instance_variable_set(:@some_characters, "hallo!")
- union.get_set_field.should == :integer32
- union.get_value.should == 27
- lambda { union.some_characters }.should raise_error(RuntimeError, "some_characters is not union's set field.")
+ expect(union.get_set_field).to eq(:integer32)
+ expect(union.get_value).to eq(27)
+ expect { union.some_characters }.to raise_error(RuntimeError, "some_characters is not union's set field.")
end
it "should serialize to binary correctly" do
@@ -114,7 +114,7 @@
other_union = SpecNamespace::My_union.new(:integer32, 25)
other_union.read(proto)
- other_union.should == union
+ expect(other_union).to eq(union)
end
it "should serialize to json correctly" do
@@ -126,24 +126,24 @@
other_union = SpecNamespace::My_union.new(:integer32, 25)
other_union.read(proto)
- other_union.should == union
+ expect(other_union).to eq(union)
end
it "should raise when validating unset union" do
union = SpecNamespace::My_union.new
- lambda { union.validate }.should raise_error(StandardError, "Union fields are not set.")
+ expect { union.validate }.to raise_error(StandardError, "Union fields are not set.")
other_union = SpecNamespace::My_union.new(:integer32, 1)
- lambda { other_union.validate }.should_not raise_error(StandardError, "Union fields are not set.")
+ expect { other_union.validate }.not_to raise_error
end
it "should validate an enum field properly" do
union = SpecNamespace::TestUnion.new(:enum_field, 3)
- union.get_set_field.should == :enum_field
- lambda { union.validate }.should raise_error(Thrift::ProtocolException, "Invalid value of field enum_field!")
+ expect(union.get_set_field).to eq(:enum_field)
+ expect { union.validate }.to raise_error(Thrift::ProtocolException, "Invalid value of field enum_field!")
other_union = SpecNamespace::TestUnion.new(:enum_field, 1)
- lambda { other_union.validate }.should_not raise_error(Thrift::ProtocolException, "Invalid value of field enum_field!")
+ expect { other_union.validate }.not_to raise_error
end
it "should properly serialize and match structs with a union" do
@@ -158,37 +158,37 @@
other_union = SpecNamespace::My_union.new(:some_characters, "hello there")
swu2 = SpecNamespace::Struct_with_union.new(:fun_union => other_union)
- swu2.should_not == swu
+ expect(swu2).not_to eq(swu)
swu2.read(proto)
- swu2.should == swu
+ expect(swu2).to eq(swu)
end
it "should support old style constructor" do
union = SpecNamespace::My_union.new(:integer32 => 26)
- union.get_set_field.should == :integer32
- union.get_value.should == 26
+ expect(union.get_set_field).to eq(:integer32)
+ expect(union.get_value).to eq(26)
end
it "should not throw an error when inspected and unset" do
- lambda{SpecNamespace::TestUnion.new().inspect}.should_not raise_error
+ expect{SpecNamespace::TestUnion.new().inspect}.not_to raise_error
end
it "should print enum value name when inspected" do
- SpecNamespace::My_union.new(:some_enum => SpecNamespace::SomeEnum::ONE).inspect.should == "<SpecNamespace::My_union some_enum: ONE (0)>"
+ expect(SpecNamespace::My_union.new(:some_enum => SpecNamespace::SomeEnum::ONE).inspect).to eq("<SpecNamespace::My_union some_enum: ONE (0)>")
- SpecNamespace::My_union.new(:my_map => {SpecNamespace::SomeEnum::ONE => [SpecNamespace::SomeEnum::TWO]}).inspect.should == "<SpecNamespace::My_union my_map: {ONE (0): [TWO (1)]}>"
+ expect(SpecNamespace::My_union.new(:my_map => {SpecNamespace::SomeEnum::ONE => [SpecNamespace::SomeEnum::TWO]}).inspect).to eq("<SpecNamespace::My_union my_map: {ONE (0): [TWO (1)]}>")
end
it "should offer field? methods" do
- SpecNamespace::My_union.new.some_enum?.should be_false
- SpecNamespace::My_union.new(:some_enum => SpecNamespace::SomeEnum::ONE).some_enum?.should be_true
- SpecNamespace::My_union.new(:im_true => false).im_true?.should be_true
- SpecNamespace::My_union.new(:im_true => true).im_true?.should be_true
+ expect(SpecNamespace::My_union.new.some_enum?).to be_falsey
+ expect(SpecNamespace::My_union.new(:some_enum => SpecNamespace::SomeEnum::ONE).some_enum?).to be_truthy
+ expect(SpecNamespace::My_union.new(:im_true => false).im_true?).to be_truthy
+ expect(SpecNamespace::My_union.new(:im_true => true).im_true?).to be_truthy
end
it "should pretty print binary fields" do
- SpecNamespace::TestUnion.new(:binary_field => "\001\002\003").inspect.should == "<SpecNamespace::TestUnion binary_field: 010203>"
+ expect(SpecNamespace::TestUnion.new(:binary_field => "\001\002\003").inspect).to eq("<SpecNamespace::TestUnion binary_field: 010203>")
end
it "should be comparable" do
@@ -207,7 +207,7 @@
for y in 0..3
for x in 0..3
# puts "#{objs[y].inspect} <=> #{objs[x].inspect} should == #{relationships[y][x]}"
- (objs[y] <=> objs[x]).should == relationships[y][x]
+ expect(objs[y] <=> objs[x]).to eq(relationships[y][x])
end
end
end