Skip to content
Browse files

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

…DB_TYPE=adapter to override
  • Loading branch information...
1 parent e70c5a0 commit 1f096a9d7d9fa856be13e24b70d430caabf6e68a @look committed
View
0 spec/db/config/database.yml → spec/db/config/database.mysql.yml
File renamed without changes.
View
0 spec/db/config/database.psql.yml → spec/db/config/database.postgresql.yml
File renamed without changes.
View
8 spec/spec_helper.rb
@@ -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.
Something went wrong with that request. Please try again.