This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,9 @@ def method_owned_by_klass?
63
63
owner = owner . class unless Module === owner
64
64
65
65
owner == @klass ||
66
- owner . singleton_class == @klass || # When `extend self` is used
66
+ # When `extend self` is used, and not under any instance of
67
+ ( owner . singleton_class == @klass &&
68
+ !Mocks . space . any_instance_recorder_for ( owner , true ) ) ||
67
69
!( method_defined_on_klass? ( owner ) )
68
70
end
69
71
end
Original file line number Diff line number Diff line change @@ -363,6 +363,21 @@ class << self; public :hello; end;
363
363
expect ( mod . hello ) . to eq ( :hello )
364
364
end
365
365
366
+ it "correctly restores from allow_any_instance_of for self extend" do
367
+ mod = Module . new {
368
+ extend self
369
+ def hello ; :hello ; end
370
+ }
371
+
372
+ allow_any_instance_of ( mod ) . to receive ( :hello ) { :stub }
373
+
374
+ expect ( mod . hello ) . to eq ( :stub )
375
+
376
+ reset_all
377
+
378
+ expect ( mod . hello ) . to eq ( :hello )
379
+ end
380
+
366
381
it "correctly handles stubbing inherited mixed in class methods" do
367
382
mod = Module . new do
368
383
def method_a
You can’t perform that action at this time.
0 commit comments