@@ -281,7 +281,7 @@ def foo
281
281
282
282
lambda {
283
283
Class . new { define_method :bar , m }
284
- } . should raise_error ( TypeError )
284
+ } . should raise_error ( TypeError , /can't bind singleton method to a different class/ )
285
285
end
286
286
287
287
it "raises a TypeError when a Method from one class is defined on an unrelated class" do
@@ -409,15 +409,29 @@ class DefineMethodSpecClass
409
409
ParentClass = Class . new { define_method ( :foo ) { :bar } }
410
410
ChildClass = Class . new ( ParentClass ) { define_method ( :foo ) { :baz } }
411
411
ParentClass . send :define_method , :foo , ChildClass . instance_method ( :foo )
412
- } . should raise_error ( TypeError )
412
+ } . should raise_error ( TypeError , /bind argument must be a subclass of ChildClass/ )
413
413
end
414
414
415
415
it "raises a TypeError when an UnboundMethod from one class is defined on an unrelated class" do
416
416
lambda {
417
417
DestinationClass = Class . new {
418
418
define_method :bar , ModuleSpecs ::InstanceMeth . instance_method ( :foo )
419
419
}
420
- } . should raise_error ( TypeError )
420
+ } . should raise_error ( TypeError , /bind argument must be a subclass of ModuleSpecs::InstanceMeth/ )
421
+ end
422
+
423
+ it "raises a TypeError when an UnboundMethod from a singleton class is defined on another class" do
424
+ c = Class . new do
425
+ class << self
426
+ def foo
427
+ end
428
+ end
429
+ end
430
+ m = c . method ( :foo ) . unbind
431
+
432
+ lambda {
433
+ Class . new { define_method :bar , m }
434
+ } . should raise_error ( TypeError , /can't bind singleton method to a different class/ )
421
435
end
422
436
end
423
437
0 commit comments