Remove Fixnum references to support modern Ruby versions
Fixnum type has been deprecated since Ruby 2.4 and removed in Ruby 3.0,
which makes BaseProtocol incompatible with modern Ruby versions.
This change removes the Fixnum reference, as well as a monkey-patch that
introduces Fixnum#ord() to Ruby versions below 1.8.7.
**This change essentially makes it officially required to use Ruby 2.4 or newer.**
Fixes the following test failures:
1) BaseProtocol Thrift::BaseProtocol should write out the different types (deprecated write_type signature)
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:256:in 'Thrift::BaseProtocol#write_type'
# ./spec/base_protocol_spec.rb:65:in 'block (3 levels) in <top (required)>'
2) BaseProtocol Thrift::BaseProtocol should write out the different types
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:256:in 'Thrift::BaseProtocol#write_type'
# ./spec/base_protocol_spec.rb:90:in 'block (3 levels) in <top (required)>'
3) BaseProtocol Thrift::BaseProtocol should read the different types (deprecated read_type signature)
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:296:in 'Thrift::BaseProtocol#read_type'
# ./spec/base_protocol_spec.rb:113:in 'block (3 levels) in <top (required)>'
4) BaseProtocol Thrift::BaseProtocol should read the different types
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:296:in 'Thrift::BaseProtocol#read_type'
# ./spec/base_protocol_spec.rb:136:in 'block (3 levels) in <top (required)>'
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index bbd502b..9a4baa8 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -227,7 +227,7 @@
it "should support optional type-checking in Thrift::Struct.new" do
Thrift.type_checking = true
begin
- expect { SpecNamespace::Hello.new(:greeting => 3) }.to raise_error(Thrift::TypeError, /Expected Types::STRING, received (Integer|Fixnum) for field greeting/)
+ expect { SpecNamespace::Hello.new(:greeting => 3) }.to raise_error(Thrift::TypeError, "Expected Types::STRING, received Integer for field greeting")
ensure
Thrift.type_checking = false
end
@@ -238,7 +238,7 @@
Thrift.type_checking = true
begin
hello = SpecNamespace::Hello.new
- expect { hello.greeting = 3 }.to raise_error(Thrift::TypeError, /Expected Types::STRING, received (Integer|Fixnum) for field greeting/)
+ expect { hello.greeting = 3 }.to raise_error(Thrift::TypeError, "Expected Types::STRING, received Integer for field greeting")
ensure
Thrift.type_checking = false
end