Permalink
Browse files

r3577@sedna: jeremy | 2005-10-13 11:55:20 -0700

 Add in_memory_connection for SQLite3 AR tests.  Uses :dbfile => ':memory:' so we don't have to manage db files.  It seems a bit quirky, so I'm including it as a separate connection type until we iron out the details.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2556 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 6627b82 commit effe522515e160349feb4a5414195aec04664e75 @jeremy jeremy committed Oct 13, 2005
Showing with 17 additions and 0 deletions.
  1. +17 −0 activerecord/test/connections/native_sqlite3/in_memory_connection.rb
@@ -0,0 +1,17 @@
+print "Using native SQLite3\n"
+require 'fixtures/course'
+require 'logger'
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+class SqliteError < StandardError
+end
+
+def make_connection(clazz, db_definitions_file)
+ clazz.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
+ File.read("#{File.dirname(__FILE__)}/../../fixtures/db_definitions/#{db_definitions_file}").split(';').each do |command|
+ clazz.connection.execute(command) unless command.strip.empty?
+ end
+end
+
+make_connection(ActiveRecord::Base, 'sqlite.sql')
+make_connection(Course, 'sqlite2.sql')

0 comments on commit effe522

Please sign in to comment.