title: ActiveRecord Rollback does not work in Rails test
body: <p>Throwing ActiveRecord::Rollback works, but not in tests.</p>
  
  <p>I've had this problem before, am now having it again, and for some reason can't find any record of someone else having this problem.</p>
  
  <p>I'm this is because tests do a rollback each time a test runs, and most databases don't support nested rolllbacks.  However, I can't be the only person with test cases that involve a transaction rollback, so perhaps I am doing something wrong.</p>
  
  <p>The following test case fails (uses shoulda library, though the same test fails with basic Test::Unit):</p>
  
  <pre><code>require 'test_helper'
  
  class RollbackTest &lt; ActiveSupport::TestCase
    context "create a record and throw rollback" do
      setup do
        User.transaction do
          User.create!
          raise ActiveRecord::Rollback
        end
      end
  
      should_not_change("count of users") { User.count }
    end
  end
  </code></pre>
  
  <p>however on the console:</p>
  
  <pre><code>?&gt; User.transaction do
  ?&gt;         User.create!
  &gt;&gt;         raise ActiveRecord::Rollback
  &gt;&gt;       end
  =&gt; nil
  &gt;&gt; User.count
  =&gt; 4
  &gt;&gt; User.transaction do
  ?&gt;         User.create!
  &gt;&gt;         raise ActiveRecord::Rollback
  &gt;&gt;       end
  =&gt; nil
  &gt;&gt; User.count
  =&gt; 4
  </code></pre>