Class: RSpec::Sidekiq::Matchers::BeExpiredIn

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_argument) ⇒ BeExpiredIn

Returns a new instance of BeExpiredIn.



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

def initialize(expected_argument)
  @expected_argument = expected_argument
end

Instance Method Details

#descriptionObject



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

def description
  "to expire in #{@expected_argument}"
end

#failure_messageObject



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

def failure_message
  "expected to expire in #{@expected_argument} but expired in #{@actual}"
end

#failure_message_when_negatedObject



21
22
23
# File 'lib/rspec/sidekiq/matchers/be_expired_in.rb', line 21

def failure_message_when_negated
  "expected to not expire in #{@expected_argument}"
end

#matches?(job) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/rspec/sidekiq/matchers/be_expired_in.rb', line 25

def matches?(job)
  @klass = job.is_a?(Class) ? job : job.class
  @actual = @klass.get_sidekiq_options['expires_in']
  @actual.to_s == @expected_argument.to_s
end