0
새로운 사용자 생성과 관련된 테스트를 작성하려고합니다. 그러나 초기 실행 후 사용자가 db에 영구적으로 남아 있기 때문에 처음에는 테스트가 실패합니다.레일 : 테스트 후에 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가 사전 테스트 상태로 되돌아 가도록하려면 어떻게해야합니까?