Bläddra i källkod

fix tests for older rubies

Joe Bolinger 6 år sedan
förälder
incheckning
604121aaa4
1 ändrade filer med 6 tillägg och 3 borttagningar
  1. 6 3
      ruby/tests/type_errors.rb

+ 6 - 3
ruby/tests/type_errors.rb

@@ -8,13 +8,16 @@ require 'google/protobuf/well_known_types'
 require 'generated_code_pb'
 
 class TestTypeErrors < Test::Unit::TestCase
+  # Ruby 2.4 unified Fixnum with Integer
+  IntegerType = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4') ? Fixnum : Integer
+
   def test_bad_string
     check_error Google::Protobuf::TypeError,
-                "Invalid argument for string field 'optional_string' (given Integer)." do
+                "Invalid argument for string field 'optional_string' (given #{IntegerType.name})." do
       A::B::C::TestMessage.new(optional_string: 4)
     end
     check_error Google::Protobuf::TypeError,
-                "Invalid argument for string field 'oneof_string' (given Integer)." do
+                "Invalid argument for string field 'oneof_string' (given #{IntegerType.name})." do
       A::B::C::TestMessage.new(oneof_string: 4)
     end
     check_error ArgumentError,
@@ -151,7 +154,7 @@ class TestTypeErrors < Test::Unit::TestCase
 
   def test_bad_msg
     check_error Google::Protobuf::TypeError,
-                "Invalid type Integer to assign to submessage field 'optional_msg'." do
+                "Invalid type #{IntegerType.name} to assign to submessage field 'optional_msg'." do
       A::B::C::TestMessage.new(optional_msg: 2)
     end
     check_error Google::Protobuf::TypeError,