test/test_helper.rb in identity_cache-0.2.5 vs test/test_helper.rb in identity_cache-0.3.0

- old
+ new

@@ -57,19 +57,19 @@ def assert_nothing_raised yield end def assert_not_nil(*args) - assert *args + assert(*args) end def assert_queries(num = 1) counter = SQLCounter.new subscriber = ActiveSupport::Notifications.subscribe('sql.active_record', counter) exception = false yield - rescue => e + rescue exception = true raise ensure ActiveSupport::Notifications.unsubscribe(subscriber) assert_equal num, counter.log.size, "#{counter.log.size} instead of #{num} queries were executed.#{counter.log.size == 0 ? '' : "\nQueries:\n#{counter.log.join("\n")}"}" unless exception @@ -78,11 +78,11 @@ def assert_memcache_operations(num) counter = CacheCounter.new subscriber = ActiveSupport::Notifications.subscribe(/cache_.*\.active_support/, counter) exception = false yield - rescue => e + rescue exception = true raise ensure ActiveSupport::Notifications.unsubscribe(subscriber) assert_equal num, counter.log.size, "#{counter.log.size} instead of #{num} memcache operations were executed. #{counter.log.size == 0 ? '' : "\nOperations:\n#{counter.log.join("\n")}"}" unless exception @@ -99,10 +99,10 @@ end end class SQLCounter cattr_accessor :ignored_sql - self.ignored_sql = [/^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/, /^BEGIN/, /^COMMIT/] + self.ignored_sql = [/^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/, /^BEGIN/, /^COMMIT/, /^SHOW /] # FIXME: this needs to be refactored so specific database can add their own # ignored SQL. This ignored SQL is for Oracle. ignored_sql.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im]