Skip to content
Browse files

Added Travis CI database config

  • Loading branch information...
1 parent f56233c commit 39d65e1a204184d8a44738dda1877faf1b0b4945 Stefan Kroes committed Dec 12, 2013
Showing with 31 additions and 2 deletions.
  1. +9 −0 .travis.yml
  2. +0 −1 Gemfile.lock
  3. +14 −0 test/database.ci.yml
  4. +8 −1 test/environment.rb
View
9 .travis.yml
@@ -25,3 +25,12 @@ matrix:
gemfile: gemfiles/mysql-ar-40.gemfile
- rvm: 1.9.2
gemfile: gemfiles/pg-ar-40.gemfile
+
+services:
+ - mysql
+ - postgresql
+ - sqlite3
+
+before_script:
+ - mysql -e 'create database ancestry_test;'
+ - psql -c 'create database ancestry_test;' -U postgres
View
1 Gemfile.lock
@@ -24,5 +24,4 @@ PLATFORMS
DEPENDENCIES
appraisal (= 1.0.0.beta1)
debugger
- rake
rdoc
View
14 test/database.ci.yml
@@ -0,0 +1,14 @@
+sqlite3:
+ adapter: sqlite3
+ database: ":memory:"
+ timeout: 500
+postgresql:
+ adapter: postgresql
+ database: ancestry_test
+ username: postgres
+ min_messages: WARNING
+mysql:
+ adapter: mysql
+ database: ancestry_test
+ username: travis
+ encoding: utf8
View
9 test/environment.rb
@@ -17,9 +17,16 @@ def self.setup
# Setup logger
logger = ActiveSupport.const_defined?(:Logger) ? :Logger : :BufferedLogger
ActiveRecord::Base.logger = ActiveSupport.const_get(logger).new('log/test.log')
+
+ # Assume Travis CI database config if no custom one exists
+ filename = if File.exists?(File.expand_path('../database.yml', __FILE__))
+ File.expand_path('../database.yml', __FILE__)
+ else
+ File.expand_path('../database.ci.yml', __FILE__)
+ end
# Setup database connection
- YAML.load(File.open(File.expand_path('../database.yml', __FILE__)).read).values.each do |config|
+ YAML.load(File.open(filename).read).values.each do |config|
begin
ActiveRecord::Base.establish_connection config
break if ActiveRecord::Base.connection

0 comments on commit 39d65e1

Please sign in to comment.
Something went wrong with that request. Please try again.