davetron5000 / optparse-plus

Start your command line scripts off right in Ruby
http://davetron5000.github.com/optparse-plus
Apache License 2.0
521 stars 54 forks source link

Unable to step into debug/pry session from inside App class #52

Closed danyoon-sge closed 11 years ago

danyoon-sge commented 12 years ago

First, thank you for the awesome methadone.

I don't know if this is by design but I am unable to step into a debug/pry session from anywhere inside the App when running the tests/features through rake. However, running from the command line bundle exec bin/my_app works fine (goes into a debugger/pry session). If this is by design, is there a workaround? I can't even see the logs using CLILogger (unless I purposely write code that will cause a syntax error and kill the running test/feature). Right now I'm resorting to File.write which is quite hacky.

Steps to reproduce

Load into a pry session so I can do normal pry related things.

Actual results:

Errors with process still alive after 3 seconds (ChildProcess::TimeoutError)

FYI, I posted this on stack overflow but this seems a more appropriate place to bring up the issue.

davetron5000 commented 12 years ago

Added an answer on stack overflow, but I think it's because a rub starts up your app in a totally different process, and there's no straightforward way to do this. You could try running the app interactively and having your cuke steps issue pry commands at that point, but that's a bit kludgy.

The hope is that your bin file doesn't have too much logic in it, so that you can test the "business" logic via unit tests.

Dave

On Sunday, September 9, 2012 at 7:46 PM, danyoon-sge wrote:

I don't know if this is by design but I am unable to step into a debug/pry session from anywhere inside the App when running the tests/features through rake. However, running from the command line bundle exec bin/my_app works fine (goes into a debugger/pry session). Steps to reproduce methadone my_app cd my_app add 'pry' as development requirement bundle install create a new feature/scenario and associated cucumber step add binding.pry somewhere in the App class rake or rake features

Expected result: Load into a pry session so I can do normal pry related things. Actual results: Errors with process still alive after 3 seconds (ChildProcess::TimeoutError) FYI, I posted this on stack overflow (http://stackoverflow.com/questions/12338049/possible-to-debug-pry-from-methadones-app-class) but this seems a more appropriate place to bring up the issue.

— Reply to this email directly or view it on GitHub (https://github.com/davetron5000/methadone/issues/52).

danyoon-sge commented 12 years ago

Thanks so much for the feedback on this. It would be very helpful if your awesome walkthrough mentioned this :smile:

Also, added a comment on the SO question - but I am able to pry into aruba steps even when run with rake features.

danyoon-sge commented 11 years ago

Paired with Avdi Grimm today and he came up with a perfect solution. http://stackoverflow.com/a/12738743/600953

Use pry-remote to connect to a pry session in the Aruba-managed subprocess.

We tried it with methadone 1.2.1 and it works great. Just remember to set the aruba timeout to longer than 3 seconds so you have time to launch pry-remote

davetron5000 commented 11 years ago

Ah, nice!

Dave

On Fri, Oct 5, 2012 at 12:30 AM, Daniel Yoon notifications@github.comwrote:

Paired with Avdi Grimm today and he came up with a perfect solution. http://stackoverflow.com/a/12738743/600953

Use pry-remote https://github.com/Mon-Ouie/pry-remote to connect to a pry session in the Aruba-managed subprocess.

We tried it with methadone 1.2.1 and it works great. Just remember to set the aruba timeout to longer than 3 seconds so you have time to launch pry-remote

— Reply to this email directly or view it on GitHubhttps://github.com/davetron5000/methadone/issues/52#issuecomment-9165196.