From: Jens Wille Date: 2008-07-23T18:40:58+09:00 Subject: Re: Is there a simple way to find a method definition? Ruby Freak [2008-07-23 06:59]: > I need to find mock_model so I can look at it (just an example) > > def mock_page(stubs={}) > @mock_page ||= mock_model(Page, stubs) > end > > Is there a simple tool/procedure to find def mock_model ? (or def > some_method_name) well, ctags is certainly a viable option. but i recently wrote a little tool [1] that traces added methods and gives you the method source right in an interactive irb session. why resort to some external tool when we have ruby :-) add this to your ~/.irbrc: require 'rubygems' require 'nuggets/util/added_methods/init' (for production use, you might want to put some conditional around that; otherwise it would be loaded in every session, which at least slows things down a bit - not to mention any possible bugs or side-effects.) then in script/console: require 'spec/rails' # if not already done puts AddedMethods[:mock_model] it's part of the ruby-nuggets gem, available from rubyforge [2] or our own gem server [3]. [1] [2] [3] cheers jens -- Jens Wille, Dipl.-Bibl. (FH) prometheus - Das verteilte digitale Bildarchiv f�r Forschung & Lehre Kunsthistorisches Institut der Universit�t zu K�ln Albertus-Magnus-Platz, D-50923 K�ln Tel.: +49 (0)221 470-6668, E-Mail: jens.wille@uni-koeln.de http://www.prometheus-bildarchiv.de/