Sha256: 306e39a599a592e60a16438ce4155b4471457cd8a6cbd0759ab3c11a6603c8b9
Contents?: true
Size: 1023 Bytes
Versions: 3
Compression:
Stored size: 1023 Bytes
Contents
require 'active_record' require 'active_record/fixtures' # Create an in-memory test database and load the fixures into it ActiveRecord::Base.establish_connection( :adapter => "sqlite3", :database => ":memory:" ) # Schema ActiveRecord::Base.silence do ActiveRecord::Migration.verbose = false load(File.join(File.dirname(__FILE__), 'schema.rb')) end # Fixtures ActiveRecord::Base.silence do Fixtures.create_fixtures(File.join(File.dirname(__FILE__), '..', 'fixtures'), ActiveRecord::Base.connection.tables) end # Models Dir[File.join(File.dirname(__FILE__), '..', 'models', '*.rb')].each { |f| require f } class << ActiveRecord::Base.connection IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SHOW FIELDS /] def execute_with_counting(sql, name = nil, &block) $query_count ||= 0 $query_count += 1 unless IGNORED_SQL.any? { |r| sql =~ r } execute_without_counting(sql, name, &block) end alias_method_chain :execute, :counting end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
arid_cache-0.1.1 | test/db/prepare.rb |
arid_cache-0.0.5 | test/db/prepare.rb |
arid_cache-0.1.0 | test/db/prepare.rb |