Sha256: ea6eaaca4942ca545d1debe54d34f867f8466dc19bf2c1b87e3f2ed2e04a47f3

Contents?: true

Size: 907 Bytes

Versions: 10

Compression:

Stored size: 907 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

# Models
Dir[File.join(File.dirname(__FILE__), '..', 'models', '*.rb')].each { |f| require f }

# Populate
require 'blueprint'
Blueprint.seeds

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

10 entries across 10 versions & 1 rubygems

Version Path
arid_cache-1.0.2 test/db/prepare.rb
arid_cache-1.0.1 test/db/prepare.rb
arid_cache-1.0.0 test/db/prepare.rb
arid_cache-0.2.7 test/db/prepare.rb
arid_cache-0.2.6 test/db/prepare.rb
arid_cache-0.2.5 test/db/prepare.rb
arid_cache-0.2.4 test/db/prepare.rb
arid_cache-0.2.3 test/db/prepare.rb
arid_cache-0.2.2 test/db/prepare.rb
arid_cache-0.2.1 test/db/prepare.rb