Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more rdoc - trying out GFM on rdoc.info again

  • Loading branch information...
commit 8f8fa3db9cc877e519f6a9d65fa4de02ac285b07 1 parent b147e12
@dchelimsky dchelimsky authored
Showing with 16 additions and 7 deletions.
  1. +16 −7 lib/rspec/mocks/message_expectation.rb
View
23 lib/rspec/mocks/message_expectation.rb
@@ -67,25 +67,34 @@ def and_return(*values, &return_block)
@return_block = block_given? ? return_block : lambda { value }
end
+ # @overload and_raise
+ # @overload and_raise(ExceptionClass)
+ # @overload and_raise(exception_instance)
+ #
# Tells the mock or stub to raise an exception when the message
# is received.
#
# @note
#
- # When you pass an exception class, the MessageExpectation will
- # raise an instance of it, creating it with +new+. If the exception
- # class initializer requires any parameters, you must pass in an
- # instance and not the class.
+ # When you pass an exception class, the MessageExpectation will raise
+ # an instance of it, creating it with `new`. If the exception class
+ # initializer requires any parameters, you must pass in an instance and
+ # not the class.
#
# @example
#
- # and_raise()
- # and_raise(Exception) #any exception class
- # and_raise(exception) #any exception object
+ # ```ruby
+ # car.stub(:go).and_raise
+ # car.stub(:go).and_raise(Exception) # any exception class
+ # car.stub(:go).and_raise(exception) # any exception object
+ # ```
def and_raise(exception=Exception)
@exception_to_raise = exception
end
+ # Tells the mock or stub to throw a symbol when the message is received.
+ #
+ # @example
def and_throw(symbol)
@symbol_to_throw = symbol
end
Please sign in to comment.
Something went wrong with that request. Please try again.