How do I use the ruby debugger with a specific test (not the whole spec file)? I want to do something like this. $ rdebug spec/models/user_spec.rb -s "should error if not new_record" ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
On 1/30/08, Jay Donnell <jaydonnell at yahoo.com> wrote:> How do I use the ruby debugger with a specific test (not the whole spec file)? I want to do something like this. > > $ rdebug spec/models/user_spec.rb -s "should error if not new_record"Almost there: $rdebug spec/models/user_spec -- s "should error if not new_record" The -- separates the rdebug options from the options for the program being debugged. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/
The other options is to do require ''ruby-debug'' in your development.rb and test.rb environment files, and just do debugger where you want the breakpoint in your test On Jan 30, 2008, at 4:15 PM, Rick DeNatale wrote:> On 1/30/08, Jay Donnell <jaydonnell at yahoo.com> wrote: >> How do I use the ruby debugger with a specific test (not the whole >> spec file)? I want to do something like this. >> >> $ rdebug spec/models/user_spec.rb -s "should error if not new_record" > > Almost there: > > $rdebug spec/models/user_spec -- s "should error if not new_record" > > The -- separates the rdebug options from the options for the program > being debugged. > > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersJames Deville http://devillecompanies.org james.deville at gmail.com rspec r3172 rspec_on_rails r3172 rails r8331
On Jan 30, 2008, at 7:21 PM, James Deville wrote:> The other options is to do require ''ruby-debug'' in your development.rb > and test.rb environment files, and just do debugger where you want the > breakpoint in your test > >I just have a ''debug'' snippet in textmate where ''debug'' => tab expands to: require ''rubygems''; require ''ruby-debug''; debugger; So I just insert this into my spec, and then rerun the specs. the debugger will pop right into the spec, allowing you to step into the method call, and so on. The only disadvantage to this approach is that you will need to run through the rest of the test in the file before hitting the debug line. Scott> On Jan 30, 2008, at 4:15 PM, Rick DeNatale wrote: > >> On 1/30/08, Jay Donnell <jaydonnell at yahoo.com> wrote: >>> How do I use the ruby debugger with a specific test (not the whole >>> spec file)? I want to do something like this. >>> >>> $ rdebug spec/models/user_spec.rb -s "should error if not >>> new_record" >> >> Almost there: >> >> $rdebug spec/models/user_spec -- s "should error if not new_record" >> >> The -- separates the rdebug options from the options for the program >> being debugged. >> >> >> -- >> Rick DeNatale >> >> My blog on Ruby >> http://talklikeaduck.denhaven2.com/ >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > James Deville > http://devillecompanies.org > james.deville at gmail.com > rspec r3172 > rspec_on_rails r3172 > rails r8331 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On 1/30/08, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> > On Jan 30, 2008, at 7:21 PM, James Deville wrote: > > > The other options is to do require ''ruby-debug'' in your development.rb > > and test.rb environment files, and just do debugger where you want the > > breakpoint in your test > > > > > > I just have a ''debug'' snippet in textmate where ''debug'' => tab > expands to: > > require ''rubygems''; require ''ruby-debug''; debugger; > > So I just insert this into my spec, and then rerun the specs. the > debugger will pop right into the spec, allowing you to step into the > method call, and so on. > > The only disadvantage to this approach is that you will need to run > through the rest of the test in the file before hitting the debug line. > > Scott > > > > On Jan 30, 2008, at 4:15 PM, Rick DeNatale wrote: > > > >> On 1/30/08, Jay Donnell <jaydonnell at yahoo.com> wrote: > >>> How do I use the ruby debugger with a specific test (not the whole > >>> spec file)? I want to do something like this. > >>> > >>> $ rdebug spec/models/user_spec.rb -s "should error if not > >>> new_record" > >> > >> Almost there: > >> > >> $rdebug spec/models/user_spec -- s "should error if not new_record" > >> > >> The -- separates the rdebug options from the options for the program > >> being debugged.Inspired by this thread, I just submitted a patch which adds a debugger option (either -u or --debugger like the Rails script/server script) which includes ruby-debug, and also ensures that the debugger method is defined if it isn''t already. This allows you to put debugger invocations in examples and stories and control whether or not they do anything using the option. http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/262-patch-add-debug-option-to-rspec-runner -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/