Class: Matchers::BeRetriedByDelayedJob

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/dunlop/matchers/be_retried_by_delayed_job.rb

Instance Method Summary collapse

Instance Method Details

#failure_messageObject



15
16
17
# File 'lib/rspec/dunlop/matchers/be_retried_by_delayed_job.rb', line 15

def failure_message
  @failure_message || "Job will not be retried"
end

#matches?(expected) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rspec/dunlop/matchers/be_retried_by_delayed_job.rb', line 3

def matches?(expected)
  @failure_message = "This expectation only works with Delayed::Worker.delay_jobs = true" and return false unless Delayed::Worker.delay_jobs
  begin
    expected.reload
  rescue => e
    @failure_message = "The job no longer exists in the database" and return false
  end

  @failure_message = "The job has a failed_at date so will not be retried" and return false unless expected.failed_at.blank?
  true
end