Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start of multi db test suite. This will help with PostgreSQL bugs

  • Loading branch information...
commit 21556713980f96ab7978fdd7687e06c7b333e1fa 1 parent 22ef8c3
@tomeric tomeric authored
View
3  .gitignore
@@ -1,4 +1,5 @@
*.log
-test.sqlite3
+*.sqlite3
/pkg/*
.bundle
+spec/database.yml
View
1  Gemfile
@@ -4,5 +4,6 @@ source :gemcutter
gem 'rails', '3.0.0.beta3'
gem 'rspec', '2.0.0.beta.8'
gem 'sqlite3-ruby', :require => 'sqlite3'
+gem 'mysql', :require => 'mysql'
gem 'jeweler'
gem 'rcov'
View
3  lib/acts_as_taggable_on/compatibility/Gemfile
@@ -3,4 +3,5 @@ source :gemcutter
# Rails 2.3
gem 'rails', '2.3.5'
gem 'rspec', '1.3.0', :require => 'spec'
-gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
+gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
+gem 'mysql', :require => 'mysql'
View
10 spec/database.yml.sample
@@ -0,0 +1,10 @@
+sqlite3:
+ adapter: sqlite3
+ database: acts_as_taggable_on.sqlite3
+
+mysql:
+ adapter: mysql
+ hostname: localhost
+ username: root
+ password:
+ database: acts_as_taggable_on
View
33 spec/spec_helper.rb
@@ -29,21 +29,24 @@ def freq
end
end
-# Setup a database
-TEST_DATABASE_FILE = File.join(File.dirname(__FILE__), '..', 'test.sqlite3')
-File.unlink(TEST_DATABASE_FILE) if File.exist?(TEST_DATABASE_FILE)
-
-ActiveRecord::Base.establish_connection(
- "adapter" => "sqlite3", "database" => TEST_DATABASE_FILE
-)
-
-ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
-ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => TEST_DATABASE_FILE
-
-ActiveRecord::Base.silence do
- ActiveRecord::Migration.verbose = false
- load(File.dirname(__FILE__) + '/schema.rb')
- load(File.dirname(__FILE__) + '/models.rb')
+ENV['DB'] ||= 'sqlite3'
+
+database_yml = File.expand_path('../database.yml', __FILE__)
+if File.exists?(database_yml)
+ active_record_configuration = YAML.load_file(database_yml)[ENV['DB']]
+
+ ActiveRecord::Base.establish_connection(active_record_configuration)
+ ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
+
+ ActiveRecord::Base.silence do
+ ActiveRecord::Migration.verbose = false
+
+ load(File.dirname(__FILE__) + '/schema.rb')
+ load(File.dirname(__FILE__) + '/models.rb')
+ end
+
+else
+ raise "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
end
def clean_database!
Please sign in to comment.
Something went wrong with that request. Please try again.