How to debug the lib?
Convenient Service has already more than 5000 unit and integration tests.
That is not the end, more specs are constantly added to cover even the craziest cases.
But since it is relatively a new library something unpredicatable may still happen.
Prefer to create a GitHub issue, when you encounter unexpected behavior.
However, if you are curious and enthusiastic enough, you can always try to dive deep and debug the "nifty" inner parts by yourself.
-
First of all, navigate to the directory with a project that uses Convenient Service as a dependency.
cd your_project
In other words, you have it in your project Gemfile like so:
Gemfilegem "convenient_service", "~> 0.19.1"
-
Make sure Convenient Service is installed.
bundle install
-
Open the gem source. Set the EDITOR env variable to your favorite code editing tool. The command below uses VS Code.
EDITOR=code bundle open convenient_service
-
Select any file you need and place a debugger call in it.
The following example utilizes byebug.
-
Start your project (irb console, Rails server, RSpec suite, Rake tasks) to trigger the code that seems to be broken.
-
Happy debugging!
dangerDo not forget to erase the debugger call once finished debugging.
cautionbinding.pry is an amazing instrument, but is NOT a debugger, it is a REPL.
REPL has a completely different purpose, it can enhance the debugger, but not replace it.
A casual REPL does not support even half of the possibilities that a mature debugger provides.
Just to name some of them, line-by-line debugging, up and down stack navigation, dynamic breakpoints, etc.
Don't like byebug since it does not highlight the syntax 🤦? Then this gist is for you.
Still don't like byebug? Use binding.break - a modern debugger developed by the Ruby core team.