Permalink
Browse files

add spec helper to list queries executed during the block

  • Loading branch information...
1 parent 352ad1b commit dc79d4322e10f1dc9977c6b3ebeb0e82d529296b @mislav committed Jul 26, 2011
Showing with 12 additions and 0 deletions.
  1. +12 −0 spec/finders/active_record_spec.rb
@@ -351,6 +351,18 @@ def run_queries(num)
QueryCountMatcher.new(num)
end
+ def show_queries(&block)
+ counter = QueryCountMatcher.new(nil)
+ counter.run block
+ ensure
+ queries = counter.performed_queries
+ if queries.any?
+ puts queries
+ else
+ puts "no queries"
+ end
+ end
+
end
class QueryCountMatcher

0 comments on commit dc79d43

Please sign in to comment.