# Need a Ruby helper for finding undefined variables and metho

**URL:** <https://www.ruby-forum.com/t/need-a-ruby-helper-for-finding-undefined-variables-and-metho/112647>\
**Category:** Ruby\
**Created:** [August 21, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/need-a-ruby-helper-for-finding-undefined-variables-and-metho/112647 "2007-08-21T20:06:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 21, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/need-a-ruby-helper-for-finding-undefined-variables-and-metho/112647/1 "2007-08-21T20:06:31Z")

</div>

Hi All,

I’m definitely a newbie. I’ve tried to read the faq first but the  
links weren’t working. I did read through some old posts.

I understand that the dynamic nature of Ruby is pretty powerful, but I  
have an application where our Ruby code is managing the execution of  
design tools that take a long time to run. We’re getting bit by having  
typos in our methods or variables that we don’t find until execution  
time, which can take hours. Is there any utility or settings in Ruby  
that can flag these at compile time?

Thanks!

-Charles

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 21, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/need-a-ruby-helper-for-finding-undefined-variables-and-metho/112647/2 "2007-08-21T21:27:44Z")

</div>

On 8/21/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> that can flag these at compile time?  
> I used unit tests and rcov for that - write simple tests that run at  
> least  
> once through the code to catch these typos. Then run them with rcov  
> (gem install rcov) to see the coverage - what code has been tested and  
> what not. Finally either write more tests for the uncovered parts or  
> look  
> at them more carefully 😉

The thoroughness of this depends on the tests you write - it’s possible  
that  
in one scenario you get object that has one particular method, and  
another  
time you get different object that hasn’t. Your goal is to cover as  
much of these  
cases as possible.

You don’t have to call your long-running stuff (=design tools?) in the  
tests -  
you should avoid them as much as possible, using so called mock objects  
to  
simulate the behavior of the expensive methods/objects. The goal is to  
have tests,  
that will quickly check your code for errors. For more info see  
test/unit, zentest  
or general test-driven development (TDD) docs.

Other than that, there’s no compile time, there’s “parse time”  
interleaved with  
“execution time”.

Try turning -w on (i.e. ruby -w ) to see more warnings.

Maybe something from ParseTree gem and friends might be useful as well,  
but  
I don’t think there’s a tool to do this particular thing (check for  
undefined methods).
