Permalink
Browse files

make it easier to test multiple databases. MySQL is the default. Set …

…DB_TYPE=adapter to override
  • Loading branch information...
look committed Feb 18, 2010
1 parent e70c5a0 commit 1f096a9d7d9fa856be13e24b70d430caabf6e68a
File renamed without changes.
View
@@ -4,6 +4,10 @@
Spec::Runner.configure do |config|
end
+def db_type
+ ENV['DB_TYPE'] ? ENV['DB_TYPE'] : 'mysql'
+end
+
def article_match?(original, copy)
copy.id.should == original.id
copy.title.should == original.title
@@ -49,7 +53,7 @@ def create_records(klass=Article, values={})
def establish_test_db
# Establish connection
unless ActiveRecord::Base.connected?
- config = YAML::load(File.open("#{SPEC}/db/config/database.yml"))
+ config = YAML::load(File.open("#{SPEC}/db/config/database.#{db_type}.yml"))
ActiveRecord::Base.configurations = config
ActiveRecord::Base.establish_connection(config['test'])
end
@@ -80,4 +84,4 @@ def migrate_up(directory='migrate')
ActiveRecord::Migrator.migrate("#{SPEC}/db/#{directory}")
@new_article_columns = columns("articles")
@new_archive_columns = columns("archived_articles")
-end
+end

0 comments on commit 1f096a9

Please sign in to comment.