Recently I needed to ‘unstub’ a method in Mocha. Browsing Mocha documentation and googling yielded no results. Apparently, Mocha doesn’t support a concept of ‘unstubbing’, i.e. recovering original implementation of a method that has been stubbed. After a little hacking, I found out that it’s quite easy (though not necessarily elegant) to call original implementation.
Category Archives: stub
Unstubbing methods in Mocha
By szeryf
4 comments | tags: alias_method, cheeseburger, hack, lolcats, mocha, ruby, stub, unit testing, unstub | posted in alias_method, cheeseburger, hack, lolcats, mocha, ruby, stub, unit testing, unstub
require ‘brain’Pages
Archives
Top Posts
- The simplest way to set-up a "we'll be back shortly" page
- Cookie handling in multi-domain applications in Ruby on Rails
- On salary negotiation during job interview
- Easy and flexible breadcrumbs for Rails
- Using assert's message to boost your unit testing productivity
- A simple shuffle that proved not so simple after all
- TextMate shortcuts you should be using
Meta
Blog Stats
- 214,106 hits

