diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-24 11:45:04 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-24 12:01:52 -0800 |
commit | dcf0558ae5da2c265d842ac532492bd6ff51e24a (patch) | |
tree | e487bb9ff49140d04d98b1ed27c4f9c23195de8c /activerecord/lib | |
parent | c973fc71254410fcab7d4560599f719b9e58a216 (diff) | |
download | rails-dcf0558ae5da2c265d842ac532492bd6ff51e24a.tar.gz rails-dcf0558ae5da2c265d842ac532492bd6ff51e24a.tar.bz2 rails-dcf0558ae5da2c265d842ac532492bd6ff51e24a.zip |
Moving AR::TestCase in to the AR tests directory
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/test_case.rb | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb index 64ecef2077..46bbe962d1 100644 --- a/activerecord/lib/active_record/test_case.rb +++ b/activerecord/lib/active_record/test_case.rb @@ -26,36 +26,5 @@ module ActiveRecord assert_equal expected.to_s, actual.to_s, message end end - - def assert_sql(*patterns_to_match) - ActiveRecord::SQLCounter.log = [] - yield - ActiveRecord::SQLCounter.log - ensure - failed_patterns = [] - patterns_to_match.each do |pattern| - failed_patterns << pattern unless ActiveRecord::SQLCounter.log.any?{ |sql| pattern === sql } - end - assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map{ |p| p.inspect }.join(', ')} not found.#{ActiveRecord::SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{ActiveRecord::SQLCounter.log.join("\n")}"}" - end - - def assert_queries(num = 1) - ActiveRecord::SQLCounter.log = [] - yield - ensure - assert_equal num, ActiveRecord::SQLCounter.log.size, "#{ActiveRecord::SQLCounter.log.size} instead of #{num} queries were executed.#{ActiveRecord::SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{ActiveRecord::SQLCounter.log.join("\n")}"}" - end - - def assert_no_queries(&block) - prev_ignored_sql = ActiveRecord::SQLCounter.ignored_sql - ActiveRecord::SQLCounter.ignored_sql = [] - assert_queries(0, &block) - ensure - ActiveRecord::SQLCounter.ignored_sql = prev_ignored_sql - end - - def sqlite3? connection - connection.class.name.split('::').last == "SQLite3Adapter" - end end end |