Skip to content

Logging database queries in unit tests

Chris Selzo edited this page Jun 26, 2018 · 1 revision

Sometimes you wanna see what Sequel is up to when you're SELECTing, FROMing, and/or WHEREing in your unit tests. The logs for all your unit tests appear in spec/artifacts/spec.log. You may want to delete this periodically as it is appended to and can get quite large!

To set up db query logging:

  1. Open spec/support/bootstrap/db_config.rb and add log_db_queries: true, to the hash returned by the config method
  2. Run your test, and tail -f or less or whatever spec/artifacts/spec.log
  3. There's no step 3
Clone this wiki locally