title: Which one does rspec run first? spec_helper.rb or db:test:prepare
body: <p>I'm trying to implement an additional check for faulty database.yml configurations. In our configuration, we follow the rails database.yml convention, which is basically adding "_#{env}" suffix to the names of the databases. We've had an incident on another project (not rails), where someone forgot to switch databases before running unit tests, causing us to lose data on the staging environment. We hacked a workaround by adding a simple check, which is: if the database name doesn't end with "_test", don't wipe it, don't run unit tests on it. </p>
  
  <p>So what is the right way of implementing this check for rails. I figured I can do it in the spec_helper.rb, but when I ran the tests after I changed the database name, instead of raising the error message that I wrote, it threw:</p>
  
  <pre><code>TinyTds::Error: Database 'some_db_name' does not exist. Make sure that the name is entered correctly.
  </code></pre>
  
  <p>Which means, it connected to the db before spec_helper.rb is loaded. I couldn't find any information on when the db:test:prepare is executed, and didn't ahve the courage to test it with an existing db that doesn't have "_test" suffix.</p>
  
  <p>Is there a hook that I can use for this?</p>