Skip to content

Instantly share code, notes, and snippets.

@carlosipe
Created May 25, 2017 10:51
Show Gist options
  • Save carlosipe/8bd1fdfa3ead2311944058f350a42caf to your computer and use it in GitHub Desktop.
Save carlosipe/8bd1fdfa3ead2311944058f350a42caf to your computer and use it in GitHub Desktop.
env_hash = Hash[File.read("env.sh").scan(/(.*?)="?(.*)"?$/)]
ENV["POSTGRESQL_URL"] = env_hash.fetch('DB_TEST')
require_relative '../main'
module Settings
def self.testing?
true
end
end
def db_test(title, &block)
DB.transaction do
test(title, &block)
raise Sequel::Rollback
end
end
# Using transactions not only serves to clean the database
# It also guarantees isolation between concurrent tests
# Note: cutest forks tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment