Method: Hardmock.restore_all_replaced_methods

Defined in:
lib/hardmock/stubbing.rb

.restore_all_replaced_methodsObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/hardmock/stubbing.rb', line 193

def restore_all_replaced_methods
  all_replaced_methods.each do |replaced|
    unless replaced.target._is_mock?
      backed_up = "_hardmock_original_#{replaced.method_name}"
      if replaced.target.methods.include?(backed_up)
        replaced.target.hm_meta_eval do
          alias_method replaced.method_name.to_sym, backed_up.to_sym 
        end
      end
      replaced.target._clear_mock
    end
  end
  all_replaced_methods.clear
end