私はActionMailerのカスタム配信メソッドを使用して電子メールを送信するrspecテストを作成しようとしています。rspecテストからカスタムアクションメーラー配信メソッドが呼び出されない
マイカスタム配信方法の実装:
class MyCustomDeliveryMethod
def deliver!(message)
puts 'Custom deliver for message: ' + message.to_s
...
end
RSpecのコード:私は 'カスタム届ける' という文字列を見ることはありませんしかし
it "should send an email" do
WebMock.allow_net_connect!
ActionMailer::Base.add_delivery_method(:api, MyCustomDeliveryMethod)
ActionMailer::Base.perform_deliveries = true
puts 'expecting this to call my custom delivery method'
ActionMailer::Base.mail(:to => '[email protected]',
:subject => 'here is a test subject sent by ActionMailer',
:body => 'here is a test body sent by <i>ActionMailer</i>',
:delivery_method => :api
)
end
test.rb
config.action_mailer.delivery_method = :api
。私の他のテストでは、クラスの他のメソッドをうまく使っています。それは単にdeliver()メソッドを起動しても機能しません。私は何が欠けていますか?
(注意:rspecでActionMailerをテストするいくつかの例がありますが、私の望むものではないメーラーの動作を嘲笑しているように見えます。
あなたの 'MyCustomMailer'メーラーは、standart' ActionMailer :: Base'から継承する必要がありますか? – Aleksey