From 49d119ae84bbb7cd180ca855cf48997dc731554c Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 16 May 2009 21:13:32 -0400 Subject: Adding spec:mysql and spec:sqlite3 tasks --- spec/connections/mysql_connection.rb | 13 +++++++++++++ spec/connections/sqlite3_connection.rb | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 spec/connections/mysql_connection.rb create mode 100644 spec/connections/sqlite3_connection.rb (limited to 'spec/connections') diff --git a/spec/connections/mysql_connection.rb b/spec/connections/mysql_connection.rb new file mode 100644 index 0000000000..789628b95d --- /dev/null +++ b/spec/connections/mysql_connection.rb @@ -0,0 +1,13 @@ +require "activerecord" +puts "Using native MySQL" + +ActiveRecord::Base.configurations = { + 'unit' => { + :adapter => 'mysql', + :username => 'rails', + :encoding => 'utf8', + :database => 'arel_unit', + } +} + +ActiveRecord::Base.establish_connection 'unit' \ No newline at end of file diff --git a/spec/connections/sqlite3_connection.rb b/spec/connections/sqlite3_connection.rb new file mode 100644 index 0000000000..bae077711d --- /dev/null +++ b/spec/connections/sqlite3_connection.rb @@ -0,0 +1,22 @@ +require "activerecord" +puts "Using native SQLite3" + +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") -- cgit v1.2.3 From dc7b51883b1cc8ad7e525b7315fb575ae77a5b3d Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 17 May 2009 16:20:40 -0400 Subject: Whitespace --- spec/connections/mysql_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/connections') diff --git a/spec/connections/mysql_connection.rb b/spec/connections/mysql_connection.rb index 789628b95d..b4e27f2380 100644 --- a/spec/connections/mysql_connection.rb +++ b/spec/connections/mysql_connection.rb @@ -10,4 +10,4 @@ ActiveRecord::Base.configurations = { } } -ActiveRecord::Base.establish_connection 'unit' \ No newline at end of file +ActiveRecord::Base.establish_connection 'unit' -- cgit v1.2.3 From d2988420fc6dd91ca751d96ed648fd1ed52ce342 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 17 May 2009 17:53:40 -0400 Subject: Added PostgreSQL to build --- spec/connections/postgresql_connection.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 spec/connections/postgresql_connection.rb (limited to 'spec/connections') diff --git a/spec/connections/postgresql_connection.rb b/spec/connections/postgresql_connection.rb new file mode 100644 index 0000000000..505dcdd1ef --- /dev/null +++ b/spec/connections/postgresql_connection.rb @@ -0,0 +1,12 @@ +require "activerecord" +puts "Using native PostgreSQL" + +ActiveRecord::Base.configurations = { + 'unit' => { + :adapter => 'postgresql', + :encoding => 'utf8', + :database => 'arel_unit', + } +} + +ActiveRecord::Base.establish_connection 'unit' -- cgit v1.2.3 From eede6962a8c1ee86b49907c1937fb0e3a38cf819 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 18 May 2009 01:50:39 -0400 Subject: Log queries to debug.log when running specs --- spec/connections/mysql_connection.rb | 2 ++ spec/connections/postgresql_connection.rb | 2 ++ spec/connections/sqlite3_connection.rb | 2 ++ 3 files changed, 6 insertions(+) (limited to 'spec/connections') diff --git a/spec/connections/mysql_connection.rb b/spec/connections/mysql_connection.rb index b4e27f2380..a58ddc35ef 100644 --- a/spec/connections/mysql_connection.rb +++ b/spec/connections/mysql_connection.rb @@ -1,6 +1,8 @@ require "activerecord" puts "Using native MySQL" +ActiveRecord::Base.logger = Logger.new("debug.log") + ActiveRecord::Base.configurations = { 'unit' => { :adapter => 'mysql', diff --git a/spec/connections/postgresql_connection.rb b/spec/connections/postgresql_connection.rb index 505dcdd1ef..e376d33ec6 100644 --- a/spec/connections/postgresql_connection.rb +++ b/spec/connections/postgresql_connection.rb @@ -1,6 +1,8 @@ require "activerecord" puts "Using native PostgreSQL" +ActiveRecord::Base.logger = Logger.new("debug.log") + ActiveRecord::Base.configurations = { 'unit' => { :adapter => 'postgresql', diff --git a/spec/connections/sqlite3_connection.rb b/spec/connections/sqlite3_connection.rb index bae077711d..649492f804 100644 --- a/spec/connections/sqlite3_connection.rb +++ b/spec/connections/sqlite3_connection.rb @@ -1,6 +1,8 @@ require "activerecord" puts "Using native SQLite3" +ActiveRecord::Base.logger = Logger.new("debug.log") + db_file = "spec/fixtures/fixture_database.sqlite3" ActiveRecord::Base.configurations = { -- cgit v1.2.3