# Breakpoint prefered way to debug?

**URL:** <https://www.ruby-forum.com/t/breakpoint-prefered-way-to-debug/79489>\
**Category:** Rails\
**Created:** [December 15, 2006, 4:59pm UTC](https://www.ruby-forum.com/t/breakpoint-prefered-way-to-debug/79489 "2006-12-15T16:59:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [December 15, 2006, 4:59pm UTC](https://www.ruby-forum.com/t/breakpoint-prefered-way-to-debug/79489/1 "2006-12-15T16:59:17Z")

</div>

Hi,

I am using rails 1.1.6 and ruby 1.8.4 (on ubuntu). In my unit test, I  
have this code:  
def test\_add\_translations  
maison = Term.find\_by\_term(‘maison’)  
breakpoint “maison”  
end

and when I get to the breakpoint session, I have no access to the  
local variable. I know there’s a problem with breakpoint and ruby  
1.8.5, but it should work with 1.8.4 (from my understanding).

So, is there a workaround? I’d prefer to continue working with my  
distribution’s ruby. Or should I use another debugging method like  
ruby-debug?

Raph

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [December 15, 2006, 5:05pm UTC](https://www.ruby-forum.com/t/breakpoint-prefered-way-to-debug/79489/2 "2006-12-15T17:05:18Z")

</div>

Honestly, for unit testing, I just use puts

def test\_add\_translations  
maison = Term.find\_by\_term(‘maison’)  
puts maison  
end

It will appear in my test window. To speed the process, I use ZenTest so  
my  
tests run when I save them

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [December 15, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/breakpoint-prefered-way-to-debug/79489/3 "2006-12-15T19:35:45Z")

</div>

On 12/15/06, Raphael B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I am using rails 1.1.6 and ruby 1.8.4 (on ubuntu). In my unit test, I

I’ve installed ruby1.8.5 and get the same problem:

irb(test\_add\_translations(TermTest)):001:0\> maison  
NameError: undefined local variable or method `maison' for #<TermTest:0xb75a11f0> from /home/xx/rails/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:432:in `method\_missing’  
from (irb):1:in `breakpoint' from /home/xx/rails/config/../vendor/rails/railties/lib/breakpoint.rb:512:in `breakpoint’  
from  
/home/xx/rails/config/…/vendor/rails/railties/lib/breakpoint.rb:512:in  
`breakpoint' from term_test.rb:48:in `test\_add\_translations’  
from /usr/lib/ruby/1.8/test/unit/testcase.rb:78:in ` __send__' from /usr/lib/ruby/1.8/test/unit/testcase.rb:78:in `run’  
from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each’  
from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run’  
from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run’  
from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in  
`run_suite' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in `start\_mediator’  
from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in  
`start' from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in `run’  
from /usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in `run' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run’  
from /usr/lib/ruby/1.8/test/unit.rb:278  
from term\_test.rb:46irb(test\_add\_translations(TermTest)):002:0\>

Raph

> So, is there a workaround? I’d prefer to continue working with my  
> distribution’s ruby. Or should I use another debugging method like  
> ruby-debug?
> 
> Raph

–  
Web database: [http://www.myowndb.com](http://www.myowndb.com)  
Free Software Developers Meeting: [http://www.fosdem.org](http://www.fosdem.org)

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [December 15, 2006, 9:04pm UTC](https://www.ruby-forum.com/t/breakpoint-prefered-way-to-debug/79489/4 "2006-12-15T21:04:03Z")

</div>

my work around for the error is to change the variable type  
(temporarily):

def test\_add\_translations  
maison = Term.find\_by\_term(‘maison’)  
@m = maison  
breakpoint  
end

then, when the test hits the breakpoint, you should be able to just  
type @m to see the value…  
dumb, but it works. i only do this if i need to _do_ something with  
the variable other than see it’s value. otherwise, a puts works ok.

Ed Hickey  
Developer  
Litmus Media  
816-533-0409  
removed\_email\_address@domain.invalid  
A Member of Think Partnership, Inc  
[www.ThinkPartnership.com](http://www.ThinkPartnership.com)  
Amex ticker symbol: THK

On 12/15/06, Raphael B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #TermTest:0xb75a11f0  
> from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in `run’
> 
> > ```
> > maison = Term.find_by_term('maison')
> > 
> > ```
> > 
> > Raph
> 
> –  
> Web database: [http://www.myowndb.com](http://www.myowndb.com)  
> Free Software Developers Meeting: [http://www.fosdem.org](http://www.fosdem.org)
> 
> >

–

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [December 16, 2006, 4:53pm UTC](https://www.ruby-forum.com/t/breakpoint-prefered-way-to-debug/79489/5 "2006-12-16T16:53:44Z")

</div>

On 12/15/06, Ed Hickey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> type @m to see the value…  
> dumb, but it works. i only do this if i need to _do_ something with  
> the variable other than see it’s value. otherwise, a puts works ok.

I’ll do that too then. I hoped there was a way to have access to local  
variables. Is there a reason why it has no more access to local  
variables?

Thanks

Raph

> > NameError: undefined local variable or method `maison' for from /usr/lib/ruby/1.8/test/unit/testcase.rb:78:in `run’  
> > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in `start’
> > 
> > > def test\_add\_translations  
> > > ruby-debug?
> 
> –
> 
> >

–  
Web database: [http://www.myowndb.com](http://www.myowndb.com)  
Free Software Developers Meeting: [http://www.fosdem.org](http://www.fosdem.org)
