[ https://issues.apache.org/jira/browse/THRIFT-4289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James E. King III resolved THRIFT-4289. --------------------------------------- Resolution: Fixed Fix Version/s: 0.12.0 > Thrift RSpec test suite fails with Ruby 2.4.x due to Fixnum deprecation > ----------------------------------------------------------------------- > > Key: THRIFT-4289 > URL: https://issues.apache.org/jira/browse/THRIFT-4289 > Project: Thrift > Issue Type: Bug > Components: Ruby - Compiler, Ruby - Library > Affects Versions: 0.10.0 > Environment: Thrift v0.10.0 > ruby 2.4.0p0 > CentOS Linux (3.10.0-514.26.2.el7.x86_64) 7 > Reporter: Jerzy J. Gangi > Assignee: James E. King III > Priority: Major > Fix For: 0.12.0 > > Attachments: thrift-4289.patch > > > h3. Steps to reproduce: > 1) Install ruby 2.4.x > 2) Build Thrift with `./bootstrap.sh`, `./configure`, `make`, and `sudo make > install` > h3. The RSpec suite will fail 3 errors: > {noformat} > Failures: > 1) Struct Thrift::Struct should support optional type-checking in > Thrift::Struct.new > Failure/Error: lambda { SpecNamespace::Hello.new(:greeting => 3) > }.should raise_error(Thrift::TypeError, "Expected Types::STRING, received > Fixnum for field greeting") > expected Thrift::TypeError with "Expected Types::STRING, received > Fixnum for field greeting", got #<Thrift::TypeError: Expected Types::STRING, > received Integer for field greeting> with backtrace: > # ./lib/thrift/types.rb:69:in `check_type' > # ./lib/thrift/struct.rb:42:in `block in initialize' > # ./lib/thrift/struct.rb:38:in `each' > # ./lib/thrift/struct.rb:38:in `initialize' > # ./spec/struct_spec.rb:230:in `new' > # ./spec/struct_spec.rb:230:in `block (4 levels) in <top (required)>' > # ./spec/struct_spec.rb:230:in `block (3 levels) in <top (required)>' > # ./spec/struct_spec.rb:230:in `block (3 levels) in <top (required)>' > 2) Struct Thrift::Struct should support optional type-checking in field > accessors > Failure/Error: lambda { hello.greeting = 3 }.should > raise_error(Thrift::TypeError, "Expected Types::STRING, received Fixnum for > field greeting") > expected Thrift::TypeError with "Expected Types::STRING, received > Fixnum for field greeting", got #<Thrift::TypeError: Expected Types::STRING, > received Integer for field greeting> with backtrace: > # ./lib/thrift/types.rb:69:in `check_type' > # ./lib/thrift/struct.rb:157:in `block in field_accessor' > # ./spec/struct_spec.rb:241:in `block (4 levels) in <top (required)>' > # ./spec/struct_spec.rb:241:in `block (3 levels) in <top (required)>' > # ./spec/struct_spec.rb:241:in `block (3 levels) in <top (required)>' > 3) Thrift::Types type checking should give the Thrift::TypeError a readable > message > Failure/Error: lambda { Thrift.check_type(3, {:type => > Thrift::Types::STRING}, :foo) }.should raise_error(Thrift::TypeError, msg) > expected Thrift::TypeError with "Expected Types::STRING, received > Fixnum for field foo", got #<Thrift::TypeError: Expected Types::STRING, > received Integer for field foo> with backtrace: > # ./lib/thrift/types.rb:69:in `check_type' > # ./spec/types_spec.rb:101:in `block (4 levels) in <top (required)>' > # ./spec/types_spec.rb:101:in `block (3 levels) in <top (required)>' > # ./spec/types_spec.rb:101:in `block (3 levels) in <top (required)>' > {noformat} > h3. Cause > Starting in Ruby 2.4, ::Fixnum is deprecated. See > https://bugs.ruby-lang.org/issues/12005 > h4. Solution > In lib/rb/spec/struct_spec.rb, change > {noformat} > lambda { SpecNamespace::Hello.new(:greeting => 3) }.should > raise_error(Thrift::TypeError, "Expected Types::STRING, received Fixnum for > field greeting") > {noformat} > to > {noformat} > lambda { SpecNamespace::Hello.new(:greeting => 3) }.should > raise_error(Thrift::TypeError, "Expected Types::STRING, received Integer for > field greeting") > {noformat} > and > {noformat} > lambda { hello.greeting = 3 }.should raise_error(Thrift::TypeError, "Expected > Types::STRING, received Fixnum for field greeting") > {noformat} > to > {noformat} > lambda { hello.greeting = 3 }.should raise_error(Thrift::TypeError, "Expected > Types::STRING, received Integer for field greeting") > {noformat} > In lib/rb/spec/types_spec.rb, change: > {noformat} > msg = "Expected Types::STRING, received Fixnum for field foo" > {noformat} > to > {noformat} > msg = "Expected Types::STRING, received Integer for field foo" > {noformat} > and > {noformat} > msg = "Expected Types::STRING, received Fixnum for field foo.element" > {noformat} > to > {noformat} > msg = "Expected Types::STRING, received Integer for field foo.element" > {noformat} > RSpec suite will then pass, and `sudo make install` will exit successfully. -- This message was sent by Atlassian JIRA (v7.6.3#76005)