Skip to content

Commit

Permalink
Add info when NO queries are executed
Browse files Browse the repository at this point in the history
  • Loading branch information
tjchambers committed Nov 8, 2018
1 parent 35e791a commit 6b58fcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def assert_sql(*patterns_to_match)
patterns_to_match.each do |pattern|
failed_patterns << pattern unless $queries_executed.any?{ |sql| pattern === sql }
end
assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map{ |p| p.inspect }.join(', ')} not found.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}"
assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map{ |p| p.inspect }.join(', ')} not found.#{$queries_executed.size == 0 ? ' None executed.' : "\nQueries:\n#{$queries_executed.join("\n")}"}"
end

def assert_queries(num = 1)
$queries_executed = []
yield
ensure
assert_equal num, $queries_executed.size, "#{$queries_executed.size} instead of #{num} queries were executed.#{$queries_executed.size == 0 ? '' : "\nQueries:\n#{$queries_executed.join("\n")}"}"
assert_equal num, $queries_executed.size, "#{$queries_executed.size} instead of #{num} queries were executed.#{$queries_executed.size == 0 ? 'None executed.' : "\nQueries:\n#{$queries_executed.join("\n")}"}"
end

def assert_no_queries
Expand Down

0 comments on commit 6b58fcf

Please sign in to comment.