Skip to content

Commit

Permalink
- Clarified some doco wrt the block on #stub.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/minitest/dev/": change = 13444]
  • Loading branch information
zenspider committed Jun 19, 2022
1 parent 61345d7 commit c748ce9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/minitest/mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Object
# NOTE: keyword args in callables are NOT checked for correctness
# against the existing method. Too many edge cases to be worth it.

def stub name, val_or_callable, *block_args, **block_kwargs
def stub name, val_or_callable, *block_args, **block_kwargs, &block
new_name = "__minitest_stub__#{name}"

metaclass = class << self; self; end
Expand Down Expand Up @@ -299,7 +299,7 @@ def stub name, val_or_callable, *block_args, **block_kwargs
end
end

yield self
block[self]
ensure
metaclass.send :undef_method, name
metaclass.send :alias_method, name, new_name
Expand Down

0 comments on commit c748ce9

Please sign in to comment.