ruby-changes:61591
From: Yuki <ko1@a...>
Date: Sun, 7 Jun 2020 02:48:50 +0900 (JST)
Subject: [ruby-changes:61591] 6d4ab96c47 (master): Make test for no method error more reliable
https://git.ruby-lang.org/ruby.git/commit/?id=6d4ab96c47 From 6d4ab96c475e7187069f3f3733fac32d6e03257c Mon Sep 17 00:00:00 2001 From: Yuki Nishijima <yk.nishijima@g...> Date: Sat, 6 Jun 2020 13:48:24 -0400 Subject: Make test for no method error more reliable This test should not depend on the bahaviour of the did_you_mean gem. diff --git a/test/ruby/test_nomethod_error.rb b/test/ruby/test_nomethod_error.rb index ed3b826..170a6c6 100644 --- a/test/ruby/test_nomethod_error.rb +++ b/test/ruby/test_nomethod_error.rb @@ -55,26 +55,30 @@ class TestNoMethodError < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_nomethod_error.rb#L55 error = NoMethodError.new("Message", :foo) assert_raise(ArgumentError) {error.receiver} - msg = defined?(DidYouMean.formatter) ? - "Message\nDid you mean? for" : "Message" + msg = "Message" error = NoMethodError.new("Message", :foo, receiver: receiver) - assert_equal([msg, :foo, receiver], - [error.message, error.name, error.receiver]) + assert_match msg, error.message + assert_equal :foo, error.name + assert_equal receiver, error.receiver error = NoMethodError.new("Message", :foo, [1, 2]) assert_raise(ArgumentError) {error.receiver} error = NoMethodError.new("Message", :foo, [1, 2], receiver: receiver) - assert_equal([msg, :foo, [1, 2], receiver], - [error.message, error.name, error.args, error.receiver]) + assert_match msg, error.message + assert_equal :foo, error.name + assert_equal [1, 2], error.args + assert_equal receiver, error.receiver error = NoMethodError.new("Message", :foo, [1, 2], true) assert_raise(ArgumentError) {error.receiver} error = NoMethodError.new("Message", :foo, [1, 2], true, receiver: receiver) - assert_equal([:foo, [1, 2], true, receiver], - [error.name, error.args, error.private_call?, error.receiver]) + assert_equal :foo, error.name + assert_equal [1, 2], error.args + assert_equal receiver, error.receiver + assert error.private_call?, "private_call? was false." end def test_message_encoding -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/