title: Rails RSpec with Multiple Databases
body: <p>I run a Rails app, and we're in the process of splitting out our signup process to a separate app. The signup app has its own separate database (for CMS and collecting prospects), but it also needs to have access to the main database. This works really well using <code>ActiveRecord::Base.establish_connection</code>. </p>
  
  <p>However, I'd like to be able to write some specs. The trouble is, how can I write specs/tests without clearing out my development database every time my tests run? If I go into the console in test mode, it's obvious the the test mode is hooked into the development database from my main app. </p>
  
  <p>Here's what my database.yml file looks like: </p>
  
  <pre><code>development: 
    database: signup_dev
  
  test:
    database: signup_test
  
  main_app_dev: 
    database: main_app_dev
  
  main_app_test: 
    database: main_app_test
  </code></pre>
  
  <p>Based on this file, I'd like <code>establish_connection</code> to connect to connect to the database <code>my_app_dev</code> in development mode, and <code>my_app_test</code> in test mode. Any ideas?</p>