From e508fc0c661fefe5228a9cab77d0c07ef220f34a Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 23 Jul 2018 11:05:28 -0700 Subject: Check the message to be encoded is the wrong type. (#4885) (#4949) * Check the message to be encoded is the wrong type. (#4885) * Change TypeError to ArgumentError --- ruby/tests/encode_decode_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ruby/tests') diff --git a/ruby/tests/encode_decode_test.rb b/ruby/tests/encode_decode_test.rb index 2bd9b98b..f8b991cd 100644 --- a/ruby/tests/encode_decode_test.rb +++ b/ruby/tests/encode_decode_test.rb @@ -84,4 +84,14 @@ class EncodeDecodeTest < Test::Unit::TestCase assert_match 'optional_int32', json end + + def test_encode_wrong_msg + e = assert_raise ::ArgumentError do + m = A::B::C::TestMessage.new( + :optional_int32 => 1, + ) + Google::Protobuf::Any.encode(m) + end + end + end -- cgit v1.2.3