From: Ruby Freak Date: 2008-07-24T05:39:16+09:00 Subject: Re: Is there a simple way to find a method definition? On Jul 23, 2:40 am, Jens Wille wrote: > 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.wi...@uni-koeln.dehttp://www.prometheus-bildarchiv.de/ That is so helpful, I will try it tonight. FYI when I went to the [1] url I got a 404 err at: http://prometheus.rubyforge.org/ruby-nuggets/classes/AddedMethods.html Thank you in a very large way