RKD
RKD

Reputation: 436

Binding.irb how to step to the next line when debugging with IRB

when usnig Binding.irb how do i.. step to the next line when debugging with IRB?

Or do i just place loads of binding.irb lines for everytime i want to pause execution for debugging purposes?

Upvotes: 3

Views: 3631

Answers (2)

Marcos Bellucci
Marcos Bellucci

Reputation: 51

next and continue, see:

From: .../spec/models/task_spec.rb @ line 17 :

    12: 
    13:   describe "is not taskable" do
    14:     let(:task) { build(:task) }
    15: 
    16:     it {
 => 17:       binding.irb
    18:       expect(task.taskable_id?).to be(false)
    19:     }
    20:   end
    21: end

irb(#<RSpec::ExampleGroups::Task:...):001> next
Loaded debug-1.8.0
(rdbg:irb) next
[13, 21] in ~/.../spec/models/task_spec.rb
    13|   describe "is not taskable" do
    14|     let(:task) { build(:task) }
    15| 
    16|     it {
    17|       binding.irb
=>  18|       expect(task.taskable_id?).to be(false)
    19|     }
    20|   end
    21| end
=>#0    block in <top (required)> (3 levels) at ~/.../models/task_spec.rb:18
  #1    [C] BasicObject#instance_exec at ~/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:263
  # and 66 frames (use `bt' command for all frames)
irb:rdbg(#<RSpec::ExampleGroups::Task:...):002> continue
.

Finished in 16.15 seconds (files took 3.99 seconds to load)
1 example, 0 failures

Upvotes: 1

Tom Lord
Tom Lord

Reputation: 28285

You can't. IRB is a REPL, but not a debugger.

Use a debugger instead, like byebug:

Usage (instead of typing binding.irb):

byebug

Then to go to the next line, type:

next

Upvotes: 4

Related Questions