Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: run code ignoring binding.pry

I often use the pry-byebug gem to put breakpoints in my code using

binding.pry 

However, during debugging (say after making a slight change) I often want to run the entire code/spec without any breakpoints for that one time.

Is there an option to do that ?. I am looking for something like

bundle exec rspec '--ignore-pry' spec/controller/my_controller.rb
like image 760
codeObserver Avatar asked Nov 06 '13 21:11

codeObserver


People also ask

How do you stop binding Pry?

If you want to exit Pry early, you can use the '!!! ' command.

Why is binding Pry not working?

To fix this just move the binding. pry command one line to the top and try to run your file again. If it still doesn't catch it, move the binding. pry command one more line to the top and keep doing this until your file catches the binding.


1 Answers

TL;DR use DISABLE_PRY=1 env variable

I had exactly the same question and I found this https://github.com/pry/pry/blob/master/spec/pry_spec.rb#L29

basically you just run

DISABLE_PRY=1 bundle exec rspec spec/controller/my_controller.rb

and you're good. Tested on this vestion of pry modules

$ cat Gemfile.lock | grep pry    
      pry (>= 0.9.12)
    pry (0.10.4)
    pry-byebug (3.4.1)
      pry (~> 0.10)
    pry-doc (0.10.0)
      pry (~> 0.9)
    pry-rails (0.3.4)
      pry (>= 0.9.10)
    pry-rescue (1.4.4)
      pry
    pry-stack_explorer (0.4.9.2)
      pry (>= 0.9.11)
like image 82
Grzegorz Avatar answered Oct 21 '22 19:10

Grzegorz