Sha256: 8bc3d86cff1ef4159a8d5baaaa7837dad257dcd691c7cef80412be96e81c5ac9

Contents?: true

Size: 824 Bytes

Versions: 9

Compression:

Stored size: 824 Bytes

Contents

require 'rails_helper'

class BreakMe < Struct.new(:bob)
  def perform
    raise "I don't work!#{bob}"
  end
end

RSpec.describe Delayed::Mailer do
  it "sends an email when a job fails" do
    Delayed::Worker.delay_jobs = true
    Delayed::Worker.max_attempts = 0
    Delayed::Job.delete_all
    ActionMailer::Base.deliveries.clear
    previous_method = ActionMailer::Base.delivery_method
    ActionMailer::Base.delivery_method = :test
    Delayed::Job.enqueue BreakMe.new("Funk")
    Delayed::Worker.new(name: 'Bunk').work_off
    Debugging::wait_until_success do
      expect(ActionMailer::Base.deliveries.count).to eq(1)
      expect(ActionMailer::Base.deliveries.first.body).to match /I don't work!Funk/
    end
    Delayed::Worker.delay_jobs = false
    ActionMailer::Base.delivery_method = previous_method
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mail_manager-3.2.25.1 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.22.0 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.7 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.6 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.5 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.4 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.2 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.1 spec/test_app/spec/models/delayed/mailer_spec.rb
mail_manager-3.2.0 spec/test_app/spec/models/delayed/mailer_spec.rb