Hi
Here is my following code:
# app/models/purchase_order.rb
class PurchaseOrder
after_create :send_po_by_mail
def send_po_by_mail
Thread.new do
begin
Notifier.generate_po(self).deliver_now
self.update_attributes(mail_status: SUCCESS)
rescue
self.update_attributes(mail_status: FAIL)
end
end
end
end
# spec/models/purchase_order_spec.rb
example "update mail status as 'success' if sent successfully" do
allow(Notifier).to receive(:generate_po).and_return(msg =
double('ActionMailer::MessageDeliver'))
allow(msg).to receive(:deliver_now).and_return(true)
po = create(:purchase_order, job: create(:job))
expect(po.reload.mail_status).to eq(PurchaseOrder::SUCCESS)
end
When I ran rspec the above test case is failing. Where I am doing wrong?
Could you help me?
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/3e0912b5-f1dc-4e7a-bcdf-871f837a122f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.