aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/connections
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-03-11 17:08:55 -0800
committerCarl Lerche <carllerche@mac.com>2010-03-11 17:10:40 -0800
commit8db90ba95d4a240fde68127e806162b3e600c383 (patch)
tree9b4ecaeb523e53c1f86cf3cb654e71de945c4e83 /spec/support/connections
parente3461239adfa972de8f25a2bc6b48b4a8aa62c9c (diff)
downloadrails-8db90ba95d4a240fde68127e806162b3e600c383.tar.gz
rails-8db90ba95d4a240fde68127e806162b3e600c383.tar.bz2
rails-8db90ba95d4a240fde68127e806162b3e600c383.zip
Move all spec support files into spec/support
Diffstat (limited to 'spec/support/connections')
-rw-r--r--spec/support/connections/mysql_connection.rb16
-rw-r--r--spec/support/connections/oracle_connection.rb19
-rw-r--r--spec/support/connections/postgresql_connection.rb15
-rw-r--r--spec/support/connections/sqlite3_connection.rb26
4 files changed, 76 insertions, 0 deletions
diff --git a/spec/support/connections/mysql_connection.rb b/spec/support/connections/mysql_connection.rb
new file mode 100644
index 0000000000..66a53b5037
--- /dev/null
+++ b/spec/support/connections/mysql_connection.rb
@@ -0,0 +1,16 @@
+puts "Using native MySQL"
+require "active_record"
+require 'logger'
+
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+ActiveRecord::Base.configurations = {
+ 'unit' => {
+ :adapter => 'mysql',
+ :username => 'root',
+ :encoding => 'utf8',
+ :database => 'arel_unit',
+ }
+}
+
+ActiveRecord::Base.establish_connection 'unit'
diff --git a/spec/support/connections/oracle_connection.rb b/spec/support/connections/oracle_connection.rb
new file mode 100644
index 0000000000..05be04e410
--- /dev/null
+++ b/spec/support/connections/oracle_connection.rb
@@ -0,0 +1,19 @@
+puts "Using native Oracle"
+require "active_record"
+require 'logger'
+
+# Prepend oracle_enhanced local development directory in front of load path
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../../oracle-enhanced/lib"
+
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+ActiveRecord::Base.configurations = {
+ 'unit' => {
+ :adapter => 'oracle_enhanced',
+ :username => 'arel_unit',
+ :password => 'arel_unit',
+ :database => 'orcl',
+ }
+}
+
+ActiveRecord::Base.establish_connection 'unit'
diff --git a/spec/support/connections/postgresql_connection.rb b/spec/support/connections/postgresql_connection.rb
new file mode 100644
index 0000000000..0fb6dfe065
--- /dev/null
+++ b/spec/support/connections/postgresql_connection.rb
@@ -0,0 +1,15 @@
+puts "Using native PostgreSQL"
+require "active_record"
+require 'logger'
+
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+ActiveRecord::Base.configurations = {
+ 'unit' => {
+ :adapter => 'postgresql',
+ :encoding => 'utf8',
+ :database => 'arel_unit',
+ }
+}
+
+ActiveRecord::Base.establish_connection 'unit'
diff --git a/spec/support/connections/sqlite3_connection.rb b/spec/support/connections/sqlite3_connection.rb
new file mode 100644
index 0000000000..abdbd24fe4
--- /dev/null
+++ b/spec/support/connections/sqlite3_connection.rb
@@ -0,0 +1,26 @@
+puts "Using native SQLite3"
+require "active_record"
+require 'logger'
+
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+db_file = "spec/support/fixtures/fixture_database.sqlite3"
+
+ActiveRecord::Base.configurations = {
+ "unit" => {
+ :adapter => 'sqlite3',
+ :database => db_file,
+ :timeout => 5000
+ }
+}
+
+unless File.exist?(db_file)
+ puts "SQLite3 database not found at #{db_file}. Rebuilding it."
+ require 'fileutils'
+ FileUtils.mkdir_p(File.dirname(db_file))
+ sqlite_command = %Q{sqlite3 "#{db_file}" "create table a (a integer); drop table a;"}
+ puts "Executing '#{sqlite_command}'"
+ raise "Seems that there is no sqlite3 executable available" unless system(sqlite_command)
+end
+
+ActiveRecord::Base.establish_connection("unit")