title: How to test that a certain function uses a transaction in Rails and rspec 2
body: <p>I have a model function that I want to make sure uses a transaction. For example:</p>
  
  <pre><code>class Model 
    def method
      Model.transaction do
        # do stuff
      end
    end
  end
  </code></pre>
  
  <p>My current approach is to stub a method call inside the block to raise an <code>ActiveRecord::Rollback</code> exception, and then check to see if the database has actually changed. But this implies that if for some reason the implementation inside the block changed, then the test would break. </p>
  
  <p>How would you test this?</p>