From 36dde35e029c7a6607e6c674062ce6fc7a51c0bd Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 27 Feb 2021 13:00:26 +0100 Subject: Update to ruby/spec@37e52e5 --- .../basicobject/singleton_method_added_spec.rb | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'spec/ruby/core/basicobject') diff --git a/spec/ruby/core/basicobject/singleton_method_added_spec.rb b/spec/ruby/core/basicobject/singleton_method_added_spec.rb index 8d256e22db..ab6b2a2d10 100644 --- a/spec/ruby/core/basicobject/singleton_method_added_spec.rb +++ b/spec/ruby/core/basicobject/singleton_method_added_spec.rb @@ -83,4 +83,63 @@ describe "BasicObject#singleton_method_added" do end ScratchPad.recorded.should == [:singleton_method_added, :new_method_with_define_method] end + + describe "when singleton_method_added is undefined" do + it "raises NoMethodError for a metaclass" do + class BasicObjectSpecs::NoSingletonMethodAdded + class << self + undef_method :singleton_method_added + end + + -> { + def self.foo + end + }.should raise_error(NoMethodError, /undefined method `singleton_method_added' for/) + end + end + + it "raises NoMethodError for a singleton instance" do + object = Object.new + class << object + undef_method :singleton_method_added + + -> { + def foo + end + }.should raise_error(NoMethodError, /undefined method `singleton_method_added' for # { + define_method(:bar) {} + }.should raise_error(NoMethodError, /undefined method `singleton_method_added' for # { + object.define_singleton_method(:baz) {} + }.should raise_error(NoMethodError, /undefined method `singleton_method_added' for #