ruby-changes:61453
From: Jean <ko1@a...>
Date: Tue, 2 Jun 2020 23:58:01 +0900 (JST)
Subject: [ruby-changes:61453] ae8362fdc8 (master): Add a spec for the new NoMethodError display of the receiver
https://git.ruby-lang.org/ruby.git/commit/?id=ae8362fdc8 From ae8362fdc89591baeb0f4d735690c17d6147f80e Mon Sep 17 00:00:00 2001 From: Jean Boussier <jean.boussier@g...> Date: Tue, 2 Jun 2020 15:33:05 +0200 Subject: Add a spec for the new NoMethodError display of the receiver diff --git a/spec/ruby/core/exception/no_method_error_spec.rb b/spec/ruby/core/exception/no_method_error_spec.rb index 55a5fcc..420e107 100644 --- a/spec/ruby/core/exception/no_method_error_spec.rb +++ b/spec/ruby/core/exception/no_method_error_spec.rb @@ -103,6 +103,24 @@ describe "NoMethodError#message" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/exception/no_method_error_spec.rb#L103 message.should include test_class.inspect end end + + ruby_version_is "2.8" do + it "uses #name to display the receiver if it is a class or a module" do + klass = Class.new { def self.name; "MyClass"; end } + begin + klass.foo + rescue NoMethodError => error + error.message.lines.first.should == "undefined method `foo' for MyClass:Class\n" + end + + mod = Module.new { def self.name; "MyModule"; end } + begin + mod.foo + rescue NoMethodError => error + error.message.lines.first.should == "undefined method `foo' for MyModule:Module\n" + end + end + end end describe "NoMethodError#dup" do -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/