ConradIrwin / pry-rescue

Start a pry session whenever something goes wrong.
MIT License
852 stars 49 forks source link

How to debug your code not RSpec?? #103

Open marko-avlijas opened 8 years ago

marko-avlijas commented 8 years ago

I guess a guide how to use this effectively is needed.
It seems this gem just rescues exception but doesn't help at all with debugging it?

I started with this:

From: /data/sites/scripts/sw_scripts/ruby/gallery/spec/specs/specs_spec.rb @ line 161 :

    156:       include_examples 'single unit type', :hp, 'HP', 0
    157:     end
    158: 
    159:     describe ':hp_per_volume' do
    160:       it 'tyring to set value/unit raises CantSetCompoundUnitError' do
 => 161:         expect {
    162:           subject.hp_per_volume = 10
    163:         }.to raise_error(CantSetCompoundUnitError)
    164:         expect {
    165:           subject.hp_per_volume = 10, 'HP/Liter'
    166:         }.to raise_error(CantSetCompoundUnitError)

RSpec::Expectations::ExpectationNotMetError: expected Specs::CantSetCompoundUnitError but nothing was raised
from /home/marko/.gem/ruby/2.3.1/gems/rspec-support-3.5.0/lib/rspec/support.rb:87:in `block in <module:Support>'
[1] pry(#<RSpec::ExampleGroups::SpecsSpecs::AttributesNotNeedingConversion::HpPerVolume>)>

I want to examine my code subject.hp_per_volume = 10 But when I press n I get thrown into a nasty spiral of RSpec internals. How do I get it to skip RSpec stuff I don't care about and move to my code?

Because this is the response I get when I press n (which should skip over not step into like s)

UncaughtThrowError: uncaught throw :breakout_nav
from /home/marko/.gem/ruby/2.3.1/gems/pry-byebug-3.4.0/lib/pry-byebug/helpers/navigation.rb:13:in `throw'

Frame number: 0/43
Frame type: method

From: /home/marko/.gem/ruby/2.3.1/gems/pry-0.10.4/lib/pry/pry_instance.rb @ line 529 Pry#select_prompt:

    524:   end
    525: 
    526:   # Returns the appropriate prompt to use.
    527:   # @return [String] The prompt.
    528:   def select_prompt
 => 529:     object = current_binding.eval('self')
    530: 
    531:     open_token = @indent.open_delimiters.any? ? @indent.open_delimiters.last :
    532:       @indent.stack.last
    533: 
    534:     c = Pry::Config.from_hash({

NoMethodError: private method `eval' called for nil:NilClass
from /home/marko/.gem/ruby/2.3.1/gems/pry-0.10.4/lib/pry/pry_instance.rb:529:in `select_prompt'
[1] pry(#<Pry>)> 

What is all this nonsense? How to get to your code? How to debug your code not RSpec?

PhilT commented 7 years ago

did you also add the pry-stack_explorer gem? That seemed to fix it for me.

cyrilchampier commented 6 years ago

we also have the pry-stack_explorer and experience the same pb