Skip to content

Instantly share code, notes, and snippets.

@nalanj
Created March 2, 2012 04:16
Show Gist options
  • Select an option

  • Save nalanj/1955584 to your computer and use it in GitHub Desktop.

Select an option

Save nalanj/1955584 to your computer and use it in GitHub Desktop.
Config to force rails to clear connections in our base environment.
TConsole::Config.run do |config|
config.preload_paths = ["./config/application"]
config.include_paths = ["./test"]
config.file_sets = {
"all" => ["#{config.test_dir}/unit/**/*_test.rb", "#{config.test_dir}/functional/**/*_test.rb",
"#{config.test_dir}/integration/**/*_test.rb"],
"units" => ["#{config.test_dir}/unit/**/*_test.rb"],
"unit" => ["#{config.test_dir}/unit/**/*_test.rb"],
"functionals" => ["#{config.test_dir}/functional/**/*_test.rb"],
"functional" => ["#{config.test_dir}/functional/**/*_test.rb"],
"integration" => ["#{config.test_dir}/integration/**/*_test.rb"]
}
config.before_load do
ENV["RAILS_ENV"] ||= "test"
end
config.after_load do
::Rails.application
::Rails::Engine.class_eval do
def eager_load!
# turn off eager_loading
end
end
if defined? ::ActiveRecord
puts "Clearing ActiveRecord connection - just in case."
::ActiveRecord::Base.clear_active_connections!
end
end
config.before_test_run do
if defined? ::ActiveRecord
::ActiveRecord::Base.clear_active_connections!
::ActiveRecord::Base.establish_connection
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment