class Nitra::RailsTooling

Public Class Methods

connect_to_database() click to toggle source

Find the database config for the current TEST_ENV_NUMBER and manually initialise a connection.

# File lib/nitra/rails_tooling.rb, line 6
def self.connect_to_database
  return unless defined?(Rails)
  # Config files are read at load time. Since we load rails in one env then
  # change some flags to get different environments through forking we need
  # always reload our database config...
  ActiveRecord::Base.configurations = YAML.load(ERB.new(IO.read("#{Rails.root}/config/database.yml")).result)

  ActiveRecord::Base.clear_all_connections!
  ActiveRecord::Base.establish_connection
end
reset_cache() click to toggle source
# File lib/nitra/rails_tooling.rb, line 17
def self.reset_cache
  return unless defined?(Rails)
  Rails.cache.reset if Rails.cache.respond_to?(:reset)
end