Skip to content

Commit c34ee07

Browse files
committed
Improve DB config in specs
1 parent 7efcedf commit c34ee07

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

spec/spec_helper.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
end
5656
end
5757

58-
require 'ajax-datatables-rails'
59-
58+
# Configure ActiveRecord
6059
adapter = ENV.fetch('DB_ADAPTER', 'postgresql')
6160

6261
options = {
@@ -65,11 +64,22 @@
6564
encoding: 'utf8'
6665
}
6766

68-
options = options.merge(host: '127.0.0.1', port: 5432, username: 'postgres', password: 'postgres') if adapter == 'postgresql'
69-
options = options.merge(host: '127.0.0.1', port: 3306, username: 'root', password: 'root') if adapter == 'mysql2'
70-
options = options.merge(username: ENV['USER'], password: ENV['USER'], database: 'xe', host: '127.0.0.1/xe') if adapter == 'oracle_enhanced'
71-
options = options.merge(database: ':memory:') if adapter == 'sqlite3'
67+
options =
68+
case adapter
69+
when 'postgresql'
70+
options.merge(host: '127.0.0.1', port: 5432, username: 'postgres', password: 'postgres')
71+
when 'mysql2'
72+
options.merge(host: '127.0.0.1', port: 3306, username: 'root', password: 'root')
73+
when 'oracle_enhanced'
74+
options.merge(host: '127.0.0.1/xe', username: ENV['USER'], password: ENV['USER'], database: 'xe')
75+
when 'sqlite3'
76+
options.merge(database: ':memory:')
77+
end
7278

7379
ActiveRecord::Base.establish_connection(options)
7480

81+
# Require our gem
82+
require 'ajax-datatables-rails'
83+
84+
# Load test helpers
7585
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].sort.each { |f| require f }

0 commit comments

Comments
 (0)