I don''t seem to be able to use the Ruby debugger functionality within the script/console tool. I want to be able to do the same kinds of things I can do with: irb -r debug (e.g. break, watch, step etc.). I want to step through the code in update_attributes to solve another problem I''m having there (which I can reproduce in script/console). I tried: ruby -r debug script/console But then I end up debugging the console script! Any ideas? Thanks. __________________________________ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/
Lawrence Oluyede
2005-Oct-13 17:24 UTC
Re: Debugging/Stepping through code in script/console?
2005/10/13, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>:> I don''t seem to be able to use the Ruby debugger > functionality within the script/console tool. I want > to be able to do the same kinds of things I can do > with: irb -r debug (e.g. break, watch, step etc.). > > I want to step through the code in update_attributes > to solve another problem I''m having there (which I can > reproduce in script/console). > > I tried: > > ruby -r debug script/console > > But then I end up debugging the console script! > > Any ideas?Did you read this? http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint Maybe it''s what you need -- Lawrence http://www.oluyede.org/blog
Yes, but that seems to just drop you into irb. I''ve also tried doing this to activate breakpoint in script/console: require ''breakpoint'' breakpoint But none of the debugging commands work. Thanks. --- Lawrence Oluyede <l.oluyede-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 2005/10/13, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>: > > I don''t seem to be able to use the Ruby debugger > > functionality within the script/console tool. I > want > > to be able to do the same kinds of things I can do > > with: irb -r debug (e.g. break, watch, step etc.). > > > > I want to step through the code in > update_attributes > > to solve another problem I''m having there (which I > can > > reproduce in script/console). > > > > I tried: > > > > ruby -r debug script/console > > > > But then I end up debugging the console script! > > > > Any ideas? > > Did you read this? >http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint> > Maybe it''s what you need > > > -- > Lawrence > http://www.oluyede.org/blog > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/
I''ve made a little progress here, if you apply this diff to your script/console: 8d7 < opt.on(''-d'', ''--debug'', ''Launch irb in debugger mode.'') { |options[:debug]| } 15d13 < libs << " -r debug" if options[:debug] And then you can start the console like this: ruby script/console --debug It''ll stop in irb/init.rb, place any breakpoints here and then enter ''c'' to continue. (rdb:1) break /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:1066 Set breakpoint 1 at /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:1066 (rdb:1) c irb(main):001:0> It''ll then fire up the familiar irb prompt and when you do something that causes it to hit a breakpoint, it''ll drop back to the rdb prompt: irb(main):002:0> p.update_attributes({:title => ''Foobar product #2''}) Breakpoint 1, attributes= at /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:1066 /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:1066: (rdb:1) For whatever reason, it doesn''t seem to be able to access sources: (rdb:1) list [1062, 1071] in /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb No sourcefile available for /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb The source file is right there ... but I can load it into emacs and follow right along. Hope this helps someone. --- Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > Yes, but that seems to just drop you into irb. I''ve > also tried doing this to activate breakpoint in > script/console: > > require ''breakpoint'' > breakpoint > > But none of the debugging commands work. > > Thanks. > > > --- Lawrence Oluyede <l.oluyede-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 2005/10/13, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>: > > > I don''t seem to be able to use the Ruby debugger > > > functionality within the script/console tool. I > > want > > > to be able to do the same kinds of things I can > do > > > with: irb -r debug (e.g. break, watch, step > etc.). > > > > > > I want to step through the code in > > update_attributes > > > to solve another problem I''m having there (which > I > > can > > > reproduce in script/console). > > > > > > I tried: > > > > > > ruby -r debug script/console > > > > > > But then I end up debugging the console script! > > > > > > Any ideas? > > > > Did you read this? > > >http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint> > > > Maybe it''s what you need > > > > > > -- > > Lawrence > > http://www.oluyede.org/blog > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/
Michael Smedberg
2005-Oct-14 02:49 UTC
Re: Debugging/Stepping through code in script/console?
This seems like a great and powerful thing to do, but I can''t get it to work the way I want. In my ideal world, I''d get an IRB/DRB session running a unit or functional test (or, even better, for a WEBrick session, but that seems more complex.) I''m having a few problems with this. First, it seems like the magic that Rails does to include application_helper.rb into models (and similar stuff) doesn''t happen if you run interactively like this. The method by which that stuff is included is mysterious to me, so I haven''t figured out how to fake it out. A workaround is to just add the "require ''application_helper''" call to the model files (not super cool, but it seems to work.) Second, I can''t figure out how to run a unit test. When I run the unit test normally, I just do something like "ruby test/unit/mytest.rb", which sets up the environment, does the proper requires, all that stuff. But when I start the drb/irb session your way, I don''t know exactly what command to run to start the test running. The ''run'' method in TestCase takes in a block, but I''m not sure what block to pass in, or how to do this manually. Does anyone know how the tests start themselves when you point Ruby at the files? This is really frustrating, since it feels like I''m just inches away from a really powerful capability (stepping into functions to see where the "real code" is, etc.) Thanks for the tip! On 10/13/05, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > > I''ve made a little progress here, if you apply this > diff to your script/console: > > 8d7 > < opt.on(''-d'', ''--debug'', ''Launch irb in debugger > mode.'') { |options[:debug]| } > 15d13 > < libs << " -r debug" if options[:debug] > > > And then you can start the console like this: > > ruby script/console --debug > > It''ll stop in irb/init.rb, place any breakpoints here > and then enter ''c'' to continue. > > (rdb:1) break > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > /lib/active_record/base.rb:1066 > Set breakpoint 1 at > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > /lib/active_record/base.rb:1066 > (rdb:1) c > irb(main):001:0> > > It''ll then fire up the familiar irb prompt and when > you do something that causes it to hit a breakpoint, > it''ll drop back to the rdb prompt: > > irb(main):002:0> p.update_attributes({:title => > ''Foobar product #2''}) > Breakpoint 1, attributes= at > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > /lib/active_record/base.rb:1066 > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > /lib/active_record/base.rb:1066: > (rdb:1) > > > For whatever reason, it doesn''t seem to be able to > access sources: > > (rdb:1) list > [1062, 1071] in > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb > No sourcefile available for > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb > > > The source file is right there ... but I can load it > into emacs and follow right along. > > Hope this helps someone. > > > --- Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > > > Yes, but that seems to just drop you into irb. I''ve > > also tried doing this to activate breakpoint in > > script/console: > > > > require ''breakpoint'' > > breakpoint > > > > But none of the debugging commands work. > > > > Thanks. > > > > > > --- Lawrence Oluyede <l.oluyede-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 2005/10/13, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>: > > > > I don''t seem to be able to use the Ruby debugger > > > > functionality within the script/console tool. I > > > want > > > > to be able to do the same kinds of things I can > > do > > > > with: irb -r debug (e.g. break, watch, step > > etc.). > > > > > > > > I want to step through the code in > > > update_attributes > > > > to solve another problem I''m having there (which > > I > > > can > > > > reproduce in script/console). > > > > > > > > I tried: > > > > > > > > ruby -r debug script/console > > > > > > > > But then I end up debugging the console script! > > > > > > > > Any ideas? > > > > > > Did you read this? > > > > > > http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint > > > > > > Maybe it''s what you need > > > > > > > > > -- > > > Lawrence > > > http://www.oluyede.org/blog > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Yes, it would seem possible to simply use simple commands like: ruby d script/server -or- ruby d test/unit/footest.rb I¹m not helping solve the problem, but if there were a way to get tests and Webrick running under the ruby debugger, it would really, Really, REALLY help. On 10/13/05 7:49 PM, "Michael Smedberg" <smedberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This seems like a great and powerful thing to do, but I can''t get it to work > the way I want. In my ideal world, I''d get an IRB/DRB session running a unit > or functional test (or, even better, for a WEBrick session, but that seems > more complex.) > > I''m having a few problems with this. > > First, it seems like the magic that Rails does to include > application_helper.rb into models (and similar stuff) doesn''t happen if you > run interactively like this. The method by which that stuff is included is > mysterious to me, so I haven''t figured out how to fake it out. A workaround > is to just add the "require ''application_helper''" call to the model files (not > super cool, but it seems to work.) > > Second, I can''t figure out how to run a unit test. When I run the unit test > normally, I just do something like "ruby test/unit/mytest.rb", which sets up > the environment, does the proper requires, all that stuff. But when I start > the drb/irb session your way, I don''t know exactly what command to run to > start the test running. The ''run'' method in TestCase takes in a block, but > I''m not sure what block to pass in, or how to do this manually. Does anyone > know how the tests start themselves when you point Ruby at the files? > > This is really frustrating, since it feels like I''m just inches away from a > really powerful capability (stepping into functions to see where the "real > code" is, etc.) > > Thanks for the tip! > > On 10/13/05, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: >> >> I''ve made a little progress here, if you apply this >> diff to your script/console: >> >> 8d7 >> < opt.on(''-d'', ''--debug'', ''Launch irb in debugger >> mode.'') { |options[:debug]| } >> 15d13 >> < libs << " -r debug" if options[:debug] >> >> >> And then you can start the console like this: >> >> ruby script/console --debug >> >> It''ll stop in irb/init.rb, place any breakpoints here >> and then enter ''c'' to continue. >> >> (rdb:1) break >> /usr/lib/ruby/gems/1.8/gems/activerecord- >> 1.11.1/lib/active_record/base.rb:1066 >> Set breakpoint 1 at >>/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:106>> 6>> (rdb:1) c >> irb(main):001:0> >> >> It''ll then fire up the familiar irb prompt and when >> you do something that causes it to hit a breakpoint, >> it''ll drop back to the rdb prompt: >> >> irb(main):002:0> p.update_attributes({:title => >> ''Foobar product #2''}) >> Breakpoint 1, attributes= at >> /usr/lib/ruby/gems/1.8/gems/activerecord- >> 1.11.1/lib/active_record/base.rb:1066 >> /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:106 >> 6: >> (rdb:1) >> >> >> For whatever reason, it doesn''t seem to be able to >> access sources: >> >> (rdb:1) list >> [1062, 1071] in >> /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb >> No sourcefile available for >> /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb >> >> >> The source file is right there ... but I can load it >> into emacs and follow right along. >> >> Hope this helps someone. >> >> >> --- Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: >> >>> > >>> > Yes, but that seems to just drop you into irb. I''ve >>> > also tried doing this to activate breakpoint in >>> > script/console: >>> > >>> > require ''breakpoint'' >>> > breakpoint >>> > >>> > But none of the debugging commands work. >>> > >>> > Thanks. >>> > >>> > >>> > --- Lawrence Oluyede <l.oluyede-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> > >>>> > > 2005/10/13, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org <mailto:davem1972@yahoo.com> >: >>>>> > > > I don''t seem to be able to use the Ruby debugger >>>>> > > > functionality within the script/console tool. I >>>> > > want >>>>> > > > to be able to do the same kinds of things I can >>> > do >>>>> > > > with: irb -r debug (e.g. break, watch, step >>> > etc.). >>>>> > > > >>>>> > > > I want to step through the code in >>>> > > update_attributes >>>>> > > > to solve another problem I''m having there (which >>> > I >>>> > > can >>>>> > > > reproduce in script/console). >>>>> > > > >>>>> > > > I tried: >>>>> > > > >>>>> > > > ruby -r debug script/console >>>>> > > > >>>>> > > > But then I end up debugging the console script! >>>>> > > > >>>>> > > > Any ideas? >>>> > > >>>> > > Did you read this? >>>> > > >>> > >> http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint >> <http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint> >>>> > > >>>> > > Maybe it''s what you need >>>> > > >>>> > > >>>> > > -- >>>> > > Lawrence >>>> > > http://www.oluyede.org/blog >>>> > > _______________________________________________ >>>> > > Rails mailing list >>>> > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>> > > >>> > http://lists.rubyonrails.org/mailman/listinfo/rails >>> <http://lists.rubyonrails.org/mailman/listinfo/rails> >>>> > > >>> > _______________________________________________ >>> > Rails mailing list >>> > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> > http://lists.rubyonrails.org/mailman/listinfo/rails >>> > >> >> >> >> >> __________________________________ >> Yahoo! Music Unlimited >> Access over 1 million songs. Try it free. >> http://music.yahoo.com/unlimited/ >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Michael Smedberg
2005-Oct-14 23:56 UTC
Re: Debugging/Stepping through code in script/console?
FYI, I couldn't figure this out, so I opened ticket 2470 for it. If anybody has further thoughts, it might be good to put them into the ticket. On 10/13/05, Steve Ross <sross@calicowebdesigns.com> wrote:> > Yes, it would seem possible to simply use simple commands like: > > ruby –d script/server > > -or- > > ruby –d test/unit/footest.rb > > I'm not helping solve the problem, but if there were a way to get tests > and Webrick running under the ruby debugger, it would really, Really, REALLY > help. > > > > > On 10/13/05 7:49 PM, "Michael Smedberg" <smedberg@gmail.com> wrote: > > This seems like a great and powerful thing to do, but I can't get it to > work the way I want. In my ideal world, I'd get an IRB/DRB session running a > unit or functional test (or, even better, for a WEBrick session, but that > seems more complex.) > > I'm having a few problems with this. > > First, it seems like the magic that Rails does to include > application_helper.rb into models (and similar stuff) doesn't happen if you > run interactively like this. The method by which that stuff is included is > mysterious to me, so I haven't figured out how to fake it out. A workaround > is to just add the "require 'application_helper'" call to the model files > (not super cool, but it seems to work.) > > Second, I can't figure out how to run a unit test. When I run the unit > test normally, I just do something like "ruby test/unit/mytest.rb", which > sets up the environment, does the proper requires, all that stuff. But when > I start the drb/irb session your way, I don't know exactly what command to > run to start the test running. The 'run' method in TestCase takes in a > block, but I'm not sure what block to pass in, or how to do this manually. > Does anyone know how the tests start themselves when you point Ruby at the > files? > > This is really frustrating, since it feels like I'm just inches away from > a really powerful capability (stepping into functions to see where the "real > code" is, etc.) > > Thanks for the tip! > > On 10/13/05, *Dave M* <davem1972@yahoo.com> wrote: > > > I've made a little progress here, if you apply this > diff to your script/console: > > 8d7 > < opt.on('-d', '--debug', 'Launch irb in debugger > mode.') { |options[:debug]| } > 15d13 > < libs << " -r debug" if options[:debug] > > > And then you can start the console like this: > > ruby script/console --debug > > It'll stop in irb/init.rb, place any breakpoints here > and then enter 'c' to continue. > > (rdb:1) break > /usr/lib/ruby/gems/1.8/gems/activerecord- 1.11.1 > /lib/active_record/base.rb:1066 > Set breakpoint 1 at > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > /lib/active_record/base.rb:1066 > (rdb:1) c > irb(main):001:0> > > It'll then fire up the familiar irb prompt and when > you do something that causes it to hit a breakpoint, > it'll drop back to the rdb prompt: > > irb(main):002:0> p.update_attributes({:title => > 'Foobar product #2'}) > Breakpoint 1, attributes= at > /usr/lib/ruby/gems/1.8/gems/activerecord- 1.11.1 > /lib/active_record/base.rb:1066 > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > /lib/active_record/base.rb:1066: > (rdb:1) > > > For whatever reason, it doesn't seem to be able to > access sources: > > (rdb:1) list > [1062, 1071] in > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb > No sourcefile available for > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb > > > The source file is right there ... but I can load it > into emacs and follow right along. > > Hope this helps someone. > > > --- Dave M <davem1972@yahoo.com> wrote: > > > > > Yes, but that seems to just drop you into irb. I've > > also tried doing this to activate breakpoint in > > script/console: > > > > require 'breakpoint' > > breakpoint > > > > But none of the debugging commands work. > > > > Thanks. > > > > > > --- Lawrence Oluyede <l.oluyede@gmail.com> wrote: > > > > > 2005/10/13, Dave M <davem1972@yahoo.com <mailto:davem1972@yahoo.com><davem1972@yahoo.com>>: > > > > I don't seem to be able to use the Ruby debugger > > > > functionality within the script/console tool. I > > > want > > > > to be able to do the same kinds of things I can > > do > > > > with: irb -r debug (e.g. break, watch, step > > etc.). > > > > > > > > I want to step through the code in > > > update_attributes > > > > to solve another problem I'm having there (which > > I > > > can > > > > reproduce in script/console). > > > > > > > > I tried: > > > > > > > > ruby -r debug script/console > > > > > > > > But then I end up debugging the console script! > > > > > > > > Any ideas? > > > > > > Did you read this? > > > > > > http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint > <http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint><http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint> > > > > > > Maybe it's what you need > > > > > > > > > -- > > > Lawrence > > > http://www.oluyede.org/blog > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > <http://lists.rubyonrails.org/mailman/listinfo/rails><http://lists.rubyonrails.org/mailman/listinfo/rails> > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I added the patch from my previous post along with some of the relevant information. Thanks. --- Michael Smedberg <smedberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> FYI, I couldn''t figure this out, so I opened ticket > 2470 for it. If anybody > has further thoughts, it might be good to put them > into the ticket. > > On 10/13/05, Steve Ross <sross-ju+vs0qJmycyYsO2DCxJlVaTQe2KTcn/@public.gmane.org> > wrote: > > > > Yes, it would seem possible to simply use simple > commands like: > > > > ruby d script/server > > > > -or- > > > > ruby d test/unit/footest.rb > > > > I''m not helping solve the problem, but if there > were a way to get tests > > and Webrick running under the ruby debugger, it > would really, Really, REALLY > > help. > > > > > > > > > > On 10/13/05 7:49 PM, "Michael Smedberg" > <smedberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > This seems like a great and powerful thing to do, > but I can''t get it to > > work the way I want. In my ideal world, I''d get an > IRB/DRB session running a > > unit or functional test (or, even better, for a > WEBrick session, but that > > seems more complex.) > > > > I''m having a few problems with this. > > > > First, it seems like the magic that Rails does to > include > > application_helper.rb into models (and similar > stuff) doesn''t happen if you > > run interactively like this. The method by which > that stuff is included is > > mysterious to me, so I haven''t figured out how to > fake it out. A workaround > > is to just add the "require ''application_helper''" > call to the model files > > (not super cool, but it seems to work.) > > > > Second, I can''t figure out how to run a unit test. > When I run the unit > > test normally, I just do something like "ruby > test/unit/mytest.rb", which > > sets up the environment, does the proper requires, > all that stuff. But when > > I start the drb/irb session your way, I don''t know > exactly what command to > > run to start the test running. The ''run'' method in > TestCase takes in a > > block, but I''m not sure what block to pass in, or > how to do this manually. > > Does anyone know how the tests start themselves > when you point Ruby at the > > files? > > > > This is really frustrating, since it feels like > I''m just inches away from > > a really powerful capability (stepping into > functions to see where the "real > > code" is, etc.) > > > > Thanks for the tip! > > > > On 10/13/05, *Dave M* <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I''ve made a little progress here, if you apply > this > > diff to your script/console: > > > > 8d7 > > < opt.on(''-d'', ''--debug'', ''Launch irb in debugger > > mode.'') { |options[:debug]| } > > 15d13 > > < libs << " -r debug" if options[:debug] > > > > > > And then you can start the console like this: > > > > ruby script/console --debug > > > > It''ll stop in irb/init.rb, place any breakpoints > here > > and then enter ''c'' to continue. > > > > (rdb:1) break > > /usr/lib/ruby/gems/1.8/gems/activerecord- 1.11.1 > > /lib/active_record/base.rb:1066 > > Set breakpoint 1 at > > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > > /lib/active_record/base.rb:1066 > > (rdb:1) c > > irb(main):001:0> > > > > It''ll then fire up the familiar irb prompt and > when > > you do something that causes it to hit a > breakpoint, > > it''ll drop back to the rdb prompt: > > > > irb(main):002:0> p.update_attributes({:title => > > ''Foobar product #2''}) > > Breakpoint 1, attributes= at > > /usr/lib/ruby/gems/1.8/gems/activerecord- 1.11.1 > > /lib/active_record/base.rb:1066 > > /usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1 > > /lib/active_record/base.rb:1066: > > (rdb:1) > > > > > > For whatever reason, it doesn''t seem to be able to > > access sources: > > > > (rdb:1) list > > [1062, 1071] in > > >/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb> > No sourcefile available for > > >/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb> > > > > > The source file is right there ... but I can load > it > > into emacs and follow right along. > > > > Hope this helps someone. > > > > > > --- Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > Yes, but that seems to just drop you into irb. > I''ve > > > also tried doing this to activate breakpoint in > > > script/console: > > > > > > require ''breakpoint'' > > > breakpoint > > > > > > But none of the debugging commands work. > > > > > > Thanks. > > > > > > > > > --- Lawrence Oluyede <l.oluyede-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > > > 2005/10/13, Dave M <davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org > <mailto:davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org><davem1972-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>>: > > > > > I don''t seem to be able to use the Ruby > debugger > > > > > functionality within the script/console > tool. I > > > > want > > > > > to be able to do the same kinds of things I > can > > > do > > > > > with: irb -r debug (e.g. break, watch, step > > > etc.). > > > > > > > > > > I want to step through the code in > > > > update_attributes > > > > > to solve another problem I''m having there > (which > > > I > > > > can > > > > > reproduce in script/console). > > > > > > > > > > I tried: > > > > > > > > > > ruby -r debug script/console > > > > > > > > > > But then I end up debugging the console > script! > > > > > > > > > > Any ideas? > > > > > > > > Did you read this? > > > > > > > > > >http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint> > ><http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint><http://wiki.rubyonrails.org/rails/pages/HowtoDebugWithBreakpoint>> > > > > > > > Maybe it''s what you need > > > > > > > > >=== message truncated ===> _______________________________________________> Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Yahoo! Mail - PC Magazine Editors'' Choice 2005 http://mail.yahoo.com