I am writing a test case in Minitest that creates an entry in a database. After starting the test, all changes that the test should perform should be discarded. What is a good way to achieve this?
require 'minitest/autorun' require 'rubygems' require 'sequel' require 'factory_girl' class TestPostgresqlFunctions < MiniTest::Unit::TestCase def test_simple_function Factory.find_definitions user = FactoryGirl.create(:user) end end
Using this code, the created record will remain in the database. I do not use Rails or other frameworks. I am using a PostgreSQL 9.1 database.
source share