From 6b58fcf42db414e351b8f3f67ddf97dd3ff8e11f Mon Sep 17 00:00:00 2001 From: Tim Chambers Date: Thu, 8 Nov 2018 15:36:08 -0800 Subject: [PATCH] Add info when NO queries are executed --- test/helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 887d2e0..fb110d0 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -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