Video

Want to see the full-length video right now for free?

Notes

In this week's video Chris is joined by Derek Prior and they run through the process used to solve a real production bug on Upcase! Check out the PR that fixes the bug discussed in this video for more context.

Debugging Workflow

  • Video 4 on Vim Integration of the Tmux trail covers the workflow used to run the specs from Vim in this video.
  • We used the rails/info route summary page to think through the routing.
  • Better errors is a wonderful replacement for the default rails error page in development
  • We use Pry to pause the spec in context and poke around, even within a template.
  • The following Vim mapping will drop in a binding.pry as needed: nmap <leader>bp orequire 'pry'; binding.pry<esc>^
  • The show-source method provided by pry will print out the source of the specified method, especially useful for library code.

Searching Through Gems

  • bundle open <gemname> will open the specified gem in your editor.
  • Bundler.vim wraps the bundle open command so you can run it from within Vim, for instance opening a gem in a new tab with :Btabedit formtastic, with tab completion of gem names!
  • By using bundle show --paths, we can get the paths to each of the gems in our bundle.
  • We can use the bundle paths to scope a grep into the bundle, as ag 'def semantic_errors' $(bundle show --paths), (using ag, aka the_silver_searcher)
  • Derek recently added a custom bundle search subcommand to the thoughtbot dotfiles in this PR

Asking For Help

Remember that when you have a bug on your hands, you are by definition in a place of not fully understanding the system. Feel free to reach out, early and often, to discuss the bug or feature you're working on. Rubber ducking, coined in the Pragmatic Programmer, is a powerful technique!