Skip to content

Instantly share code, notes, and snippets.

@rtwomey
Created July 30, 2012 20:24
Show Gist options
  • Save rtwomey/3209869 to your computer and use it in GitHub Desktop.
Save rtwomey/3209869 to your computer and use it in GitHub Desktop.
Print SQL from your ruby tests
Helpful debugging trick:
When running a focused test, sometimes it's useful to log the SQL generated by the test. Stick the following in your test:
ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)
Rerun your focused test and bask in the loveliness that is your test's SQL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment