Rails/Rspec: Testing delayed_job mails

前端 未结 5 912
你的背包
你的背包 2021-02-01 17:37

Just wondering how to test that actionmailer requests are actually sent to the delayed_job que in rspec.

I would have assumed it was quite simple, but my delayed_job que

5条回答
  •  你的背包
    2021-02-01 17:53

    @zetetic I think we have to pass block in change method here.

    It shoulb be like this:

    it "queues mail when a contact is created" do
    Contact.stub(:new) { mock_model(Contact,:save => true) }
    expect {
        post :create, {}
      }.to change { Delayed::Job.count }.by(1)
    end
    

提交回复
热议问题