2013-02-05 14:16:51 -05:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rails'
|
|
|
|
require 'active_record'
|
|
|
|
|
|
|
|
|
|
|
|
ENV["RAILS_ENV"] ||= 'test'
|
|
|
|
RSpec.configure do |config|
|
|
|
|
|
2013-11-05 19:42:00 -05:00
|
|
|
require 'sqlite3'
|
|
|
|
class SQLite3::Database
|
|
|
|
def self.query_log
|
|
|
|
@@query_log ||= []
|
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :old_execute, :execute
|
|
|
|
alias_method :old_prepare, :prepare
|
|
|
|
|
|
|
|
def execute(*args,&blk)
|
|
|
|
self.class.query_log << [args, caller, Thread.current.object_id]
|
|
|
|
old_execute(*args,&blk)
|
|
|
|
end
|
|
|
|
|
|
|
|
def prepare(*args,&blk)
|
|
|
|
self.class.query_log << [args, caller, Thread.current.object_id]
|
|
|
|
old_prepare(*args,&blk)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
config.color_enabled = true
|
2013-02-25 11:42:20 -05:00
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
config.before(:suite) do
|
|
|
|
ActiveRecord::Base.configurations['test'] = (YAML::load(File.open("spec/fixtures/database.yml"))['test'])
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|