3
mail (mail_content) .deliver 에 대한 호출이 될 rspec 테스트를 작성하는 가장 좋은 방법을 찾으려고합니다. Rails.logger가 호출되었다고 주장 할 수 있습니다.슈퍼 클래스 메서드를 테스트하는 방법 Ruby에서 rspec을 사용하여 예외를 throw하는 방법
나는 테스트 대상 클래스를 조롱 할 의도가 없다는 것을 알고 있지만 이것은 수퍼 클래스에도 적용 되는가?
class MyMailer < ActionMailer::Base
default from: '[email protected]'
default charset: 'UTF-8'
default content_type: 'text/plain'
default subject: 'Test'
def send_email (to, mail_headers_hash, mail_body)
begin
headers mail_headers_hash
mail_content = {to: to, body: mail_body}
mail(mail_content).deliver
rescue ArgumentError, StandardError => e
Rails.logger.error "Failed to email order response - #{e}"
end
end
end
end