lib/mocha/object_methods.rb
# Removes the specified stubbed methods (added by calls to {#expects} or {#stubs}) and all expectations associated with them.
#
# Restores the original behaviour of the methods before they were stubbed. This is normally done automatically at the end of each test, but in some circumstances you may want to do it *before* the end of the test.
#
# WARNING: If you {#unstub} a method which still has unsatisfied expectations, you may be removing the only way those expectations can be satisfied. Use {#unstub} with care.
#
# @param [Array<Symbol>] method_names names of methods to unstub.
#
# @example Stubbing and unstubbing a method on a real (non-mock) object.
#   multiplier = Multiplier.new
#   multiplier.double(2) # => 4
#   multiplier.stubs(:double).raises # new behaviour defined
#   multiplier.double(2) # => raises exception
#   multiplier.unstub(:double) # original behaviour restored
#   multiplier.double(2) # => 4
#
# @example Unstubbing multiple methods on a real (non-mock) object.
#   multiplier.unstub(:double, :triple)
#
#   # exactly equivalent to
#
#   multiplier.unstub(:double)
#   multiplier.unstub(:triple)
Removes the specified stubbed methods (added by calls to {#expects} or {#stubs}) and all expectations associated with them.
Restores the original behaviour of the methods before they were stubbed. This is normally done automatically at the end of each test, but in some circumstances you may want to do it *before* the end of the test.

If you {#unstub} a method which still has unsatisfied expectations, you may be removing the only way those expectations can be satisfied. Use {#unstub} with care.
Removes the specified stubbed methods ( added by calls to { #expects } or { #stubs } ) and all expectations associated with them . Restores the original behaviour of the methods before they were stubbed . This is normally done automatically at the end of each test but in some circumstances you may want to do it * before * the end of the test . If you { #unstub } a method which still has unsatisfied expectations you may be removing the only way those expectations can be satisfied . Use { #unstub } with care .
def unstub(*method_names)
      mockery = Mocha::Mockery.instance
      method_names.each do |method_name|
        method = stubba_method.new(stubba_object, method_name)
        mockery.stubba.unstub(method)
      end
    end
def unstub ( * method_names ) mockery = Mocha :: Mockery . instance method_names . each do | method_name | method = stubba_method . new ( stubba_object , method_name ) mockery . stubba . unstub ( method ) end end
Removes the specified stubbed methods (added by calls to {#expects} or {#stubs}) and all expectations associated with them.
Removes the specified stubbed methods ( added by calls to { #expects } or { #stubs } ) and all expectations associated with them .
method_names
method_names names of methods to unstub.
method_names names of methods to unstub .
example
Stubbing and unstubbing a method on a real (non-mock) object. multiplier = Multiplier.new multiplier.double(2) # => 4 multiplier.stubs(:double).raises # new behaviour defined multiplier.double(2) # => raises exception multiplier.unstub(:double) # original behaviour restored multiplier.double(2) # => 4
Stubbing and unstubbing a method on a real ( non - mock ) object . multiplier = Multiplier . new multiplier . double ( 2 ) # = > 4 multiplier . stubs ( : double ) . raises # new behaviour defined multiplier . double ( 2 ) # = > raises exception multiplier . unstub ( : double ) # original behaviour restored multiplier . double ( 2 ) # = > 4
example
Unstubbing multiple methods on a real (non-mock) object. multiplier.unstub(:double, :triple) # exactly equivalent to multiplier.unstub(:double) multiplier.unstub(:triple)
Unstubbing multiple methods on a real ( non - mock ) object . multiplier . unstub ( : double : triple ) # exactly equivalent to multiplier . unstub ( : double ) multiplier . unstub ( : triple )