Skip to content

Commit

Permalink
spec: make local testing Just Work™
Browse files Browse the repository at this point in the history
when using homebrew pg/mysql, anyway
  • Loading branch information
jenseng committed Aug 8, 2018
1 parent 3f431e6 commit ab5eec4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion database.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
defaults: &defaults
database: hairtrigger_schema_test
username: hairtrigger
host: localhost
test:
mysql: &mysql_defaults
<<: *defaults
username: root
mysql2: &mysql2_defaults
<<: *defaults
username: root
postgresql: &postgres_defaults
<<: *defaults
min_messages: error
Expand Down
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ def initialize_db
ret = `echo "drop database if exists #{config['database']}; create database #{config['database']};" | mysql -u #{config['username']}`
raise "error creating database: #{ret}" unless $?.exitstatus == 0
when :postgresql
`dropdb -U #{config['username']} #{config['database']} &>/dev/null`
ret = `createdb -U #{config['username']} #{config['database']} 2>&1`
user_arg = "-U #{config['username']}" if config['username']
`dropdb #{user_arg} #{config['database']} &>/dev/null`
ret = `createdb #{user_arg} #{config['database']} 2>&1`
raise "error creating database: #{ret}" unless $?.exitstatus == 0
end
# Arel has an issue in that it keeps using original connection for quoting,
Expand Down

0 comments on commit ab5eec4

Please sign in to comment.