title: Rails 3 Rspec test database persists
body: <p>I am having a problem with my test database not wiping the data after each run.  I also have cucumber tests and the database is cleared each time when I run those.</p>
  
  <p>The following spec test only works immediately after a rake db:test:prepare, is there something wrong with my test or the spec_helper.rb that is causing the data to persist?</p>
  
  <p>My spec test is:</p>
  
  <pre><code>require "spec_helper"
  
  describe "/api/v1/offers", :type =&gt; :api do
    Factory(:offer)
    context "index" do
      let(:url) { "/api/v1/offers" }
      it "JSON" do
        get "#{url}.json"
        last_response.status.should eql(200)
        last_response.body.should eql(Offer.all.to_json(:methods =&gt; [:merchant_image_url, :remaining_time, :formatted_price]))
        projects = JSON.parse(last_response.body)
        projects.any? { |p| p["offer"]["offer"] == "Offer 1" }.should be_true
      end
  
      it "XML" do
        get "#{url}.xml"
        last_response.body.should eql(Offer.all.to_xml(:methods =&gt; [:merchant_image_url, :remaining_time, :formatted_price]))
        projects = Nokogiri::XML(last_response.body)
        projects.css("offer offer").text.should eql("Offer 1")
      end
    end
  end
  </code></pre>
  
  <p>My spec/spec_helper.rb file looks like this:</p>
  
  <pre><code>ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  
  RSpec.configure do |config|
    config.mock_with :rspec
  
  
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
  
    config.use_transactional_fixtures = true
  end
  </code></pre>
  
  <p>Cheers,
  Gazler.</p>