Skip to content

Commit

Permalink
Add note and example for yield with no args
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Nov 1, 2020
1 parent 1b76e4d commit 0085b60
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/mocha/expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def with_no_block_given
#
# May be called multiple times on the same expectation for consecutive invocations.
#
# If no +parameters+ are given then it will yield the block provided.
#
# @param [*Array] parameters parameters to be yielded.
# @return [Expectation] the same expectation, thereby allowing invocations of other {Expectation} methods to be chained.
# @see #then
Expand Down Expand Up @@ -292,6 +294,13 @@ def with_no_block_given
# sum # => 1
# fibonacci.next_pair { |first, second| sum = first + second }
# sum # => 2
#
# @example Yield the provided block
# object = mock()
# object.expects(:log).yields
# messages = ""
# object.log { messages += "log called" }
# messages # => "log called"
def yields(*parameters)
multiple_yields(parameters)
end
Expand Down

0 comments on commit 0085b60

Please sign in to comment.