aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/helper.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-06-12 18:09:09 +0100
committerJon Leighton <j@jonathanleighton.com>2011-06-12 18:19:21 +0100
commit14e6bbb149a7045d73d34deed2c8ef4a47e4233f (patch)
tree807d803443c6c7778f63b3bd720f477d3917542a /activerecord/test/cases/helper.rb
parentde01a6410207efd9554e9d1ed901c180e54d632a (diff)
downloadrails-14e6bbb149a7045d73d34deed2c8ef4a47e4233f.tar.gz
rails-14e6bbb149a7045d73d34deed2c8ef4a47e4233f.tar.bz2
rails-14e6bbb149a7045d73d34deed2c8ef4a47e4233f.zip
Refactor tests to be less brittle
Diffstat (limited to 'activerecord/test/cases/helper.rb')
-rw-r--r--activerecord/test/cases/helper.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb
index 85c20179ec..aa5f1f528f 100644
--- a/activerecord/test/cases/helper.rb
+++ b/activerecord/test/cases/helper.rb
@@ -58,11 +58,12 @@ end
module ActiveRecord
class SQLCounter
- 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/]
+ 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/]
# 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]
+ ignored_sql.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im]
def initialize
$queries_executed = []
@@ -74,7 +75,7 @@ module ActiveRecord
# FIXME: this seems bad. we should probably have a better way to indicate
# the query was cached
unless 'CACHE' == values[:name]
- $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
+ $queries_executed << sql unless self.class.ignored_sql.any? { |r| sql =~ r }
end
end
end