0
私は新しいユーザーを作成するテストを作成しようとしています。ただし、最初の実行後にユーザーがdbに永続的に存在するため、テストはすべて失敗します。Rails:テスト後にdbが元の状態に戻るようにするにはどうすればよいですか?
require 'test_helper'
require 'minitest/autorun'
describe UserMailer < ActionMailer::TestCase do
it 'will send an email when a new user is created' do
original_mail_count = ActionMailer::Base.deliveries.count
User.create(email: "[email protected]", password: "password").save
ActionMailer::Base.deliveries.count.must_equal original_mail_count + 1
end
end
テストの実行後にdbがテスト前の状態に戻ることを確認する方法を教えてください。