Debuggging




Or how I debug.




Jason Wieringa                                                                        

Agenda



  1.  Some things I've learned
  2.  Share your tips!

Pry




gem install pry

What is it?


It's not a debugger.


It's an IRB alternative with different bells and whistles.

WHY?


I have this method... it is long.

I didn't write it.
 Of course.

But has MANY instance variables and there's something wrong with one of them.

I don't know which.

WHy Continued


I could start doing this all over

puts @the_thing_I_want_to_see


But, it would be really great to step around the state and play with the code in real time.


Can I do that?



Usage




binding.pry

cd and Ls


pry(#<AssessmentsController>)> cd Assessment
pry(Assessment):1>

pry(Assessment):1> ls
constants: END_DATE_OPTIONS MongoMapperAssociations MongoMapperKeys
Object.methods: yaml_tag
ActiveModel::Naming#methods: model_name
ActiveModel::Translation#methods: human_attribute_name lookup_ancestors
MongoMapper::Plugins::Document::ClassMethods#methods: embeddable?

show-method


pry(Assessment):1> show-method released?

From: /Users/jason/prj/codesherpas/complete_communicator/app/models/assessment.rb @ line 61:
Owner: Assessment
Visibility: public
Number of lines: 3

def released?
released
end
[74] pry(Assessment):1>

Find-method, show-source


pry(Assessment):1> find-method to_yaml
Object
Object#psych_to_yaml
Object#to_yaml_properties
Object#to_yaml

pry(Assessment):1> show-source to_yaml

From: /Users/jason/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/psych/core_ext.rb @ line 13:
Owner: Object
Visibility: public
Number of lines: 3

def psych_to_yaml options = {}
Psych.dump self, options
end 

A little more


Ruby!

instance_methods

instance_variables

More Pry

_ex_

wtf

Pry-debugger




gem install pry-debugger

The pay Off



  • step
  • next
  • finish
  • continue

Resources


There is a lot!!



  • Keep it simple
  • Watch others
  • Try one new thing

Your Tips!

Made with Slides.com