Gems for debugging
As you probably guessed, the Ruby community came across the debugging problem just like any other programming community and thus has come up with libraries (or gems) to encapsulate different debug behaviors. We’ll talk specifically about three gems that make your debugging experience a whole different path than just dumping values in your code:
- Debug
- Pry
- Byebug
All of these gems were designed for the same purpose, but each one has its own peculiarities and it will depend on your own preference which one you choose to use in your projects. Let’s start by looking at the first one.
The debug gem
This gem comes as a replacement (and improvement) to the traditional lib/debug.rb
standard library. While there are various ways to use this gem, let’s start by installing our gem and creating a simple debuggable example. First, we will have to do some setup. Let’s use a Gemfile, which we learned about in previous chapters...