aboutsummaryrefslogtreecommitdiffstats
path: root/spec/connections
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-05-26 12:41:52 -0300
committerEmilio Tagua <miloops@gmail.com>2009-05-26 12:41:52 -0300
commitc9bbea6115be520dbd47bd30108c5622289deb26 (patch)
treeec418e01954c1bd2dcfebc7fbc8220fb04b50baf /spec/connections
parentae1e0ac5e98a7e5a2894d0a431f8c34af6575cae (diff)
parent86364591af807ed3fa4a7304f53e6f3458cb4961 (diff)
downloadrails-c9bbea6115be520dbd47bd30108c5622289deb26.tar.gz
rails-c9bbea6115be520dbd47bd30108c5622289deb26.tar.bz2
rails-c9bbea6115be520dbd47bd30108c5622289deb26.zip
Merge commit 'brynary/master'
Conflicts: lib/arel.rb lib/arel/session.rb
Diffstat (limited to 'spec/connections')
-rw-r--r--spec/connections/mysql_connection.rb15
-rw-r--r--spec/connections/postgresql_connection.rb14
-rw-r--r--spec/connections/sqlite3_connection.rb25
3 files changed, 54 insertions, 0 deletions
diff --git a/spec/connections/mysql_connection.rb b/spec/connections/mysql_connection.rb
new file mode 100644
index 0000000000..a58ddc35ef
--- /dev/null
+++ b/spec/connections/mysql_connection.rb
@@ -0,0 +1,15 @@
+require "activerecord"
+puts "Using native MySQL"
+
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+ActiveRecord::Base.configurations = {
+ 'unit' => {
+ :adapter => 'mysql',
+ :username => 'rails',
+ :encoding => 'utf8',
+ :database => 'arel_unit',
+ }
+}
+
+ActiveRecord::Base.establish_connection 'unit'
diff --git a/spec/connections/postgresql_connection.rb b/spec/connections/postgresql_connection.rb
new file mode 100644
index 0000000000..e376d33ec6
--- /dev/null
+++ b/spec/connections/postgresql_connection.rb
@@ -0,0 +1,14 @@
+require "activerecord"
+puts "Using native PostgreSQL"
+
+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/connections/sqlite3_connection.rb b/spec/connections/sqlite3_connection.rb
new file mode 100644
index 0000000000..9e9503e0ca
--- /dev/null
+++ b/spec/connections/sqlite3_connection.rb
@@ -0,0 +1,25 @@
+require "rubygems"
+require "activerecord"
+puts "Using native SQLite3"
+
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+db_file = "spec/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."
+ 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")