Class: RSpec::Sidekiq::Matchers::BeRetryable

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/sidekiq/matchers/be_retryable.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ BeRetryable

Returns a new instance of BeRetryable.



9
10
11
# File 'lib/rspec/sidekiq/matchers/be_retryable.rb', line 9

def initialize expected
  @expected = expected
end

Instance Method Details

#descriptionObject



13
14
15
# File 'lib/rspec/sidekiq/matchers/be_retryable.rb', line 13

def description
  "retry #{number_of_description} times"
end

#failure_messageObject



17
18
19
# File 'lib/rspec/sidekiq/matchers/be_retryable.rb', line 17

def failure_message
  "expected #{@klass} to retry #{number_of_description} times but got #{@actual}"
end

#matches?(job) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/rspec/sidekiq/matchers/be_retryable.rb', line 21

def matches? job
  @klass = job.class
  @actual = @klass.get_sidekiq_options["retry"]
  @actual == @expected
end

#negative_failure_messageObject



27
28
29
# File 'lib/rspec/sidekiq/matchers/be_retryable.rb', line 27

def negative_failure_message
  "expected #{@klass} to not retry #{number_of_description} times"
end

#number_of_descriptionObject



31
32
33
# File 'lib/rspec/sidekiq/matchers/be_retryable.rb', line 31

def number_of_description
  @expected.is_a?(Fixnum) ? @expected : "the default number of"
end