Class: RSpec::Sidekiq::Matchers::BeUnique::Base
- Inherits:
-
Object
- Object
- RSpec::Sidekiq::Matchers::BeUnique::Base
show all
- Defined in:
- lib/rspec/sidekiq/matchers/be_unique.rb
Instance Method Summary
collapse
Instance Method Details
#description ⇒ Object
22
23
24
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 22
def description
'be unique in the queue'
end
|
#expiration_matches? ⇒ Boolean
62
63
64
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 62
def expiration_matches?
@expected_expiration.nil? || actual_expiration == @expected_expiration
end
|
#failure_message ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 26
def failure_message
if !interval_matches? && @expected_interval
"expected #{@klass} to be unique for #{@expected_interval} seconds, " \
"but its interval was #{actual_interval} seconds"
elsif !expiration_matches?
"expected #{@klass} to be unique until #{@expected_expiration}, " \
"but its unique_until was #{actual_expiration || 'not specified'}"
else
"expected #{@klass} to be unique in the queue"
end
end
|
#failure_message_when_negated ⇒ Object
66
67
68
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 66
def failure_message_when_negated
"expected #{@klass} to not be unique in the queue"
end
|
#for(interval) ⇒ Object
44
45
46
47
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 44
def for(interval)
@expected_interval = interval
self
end
|
#interval_matches? ⇒ Boolean
58
59
60
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 58
def interval_matches?
!interval_specified? || actual_interval == @expected_interval
end
|
#interval_specified? ⇒ Boolean
54
55
56
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 54
def interval_specified?
@expected_interval
end
|
#matches?(job) ⇒ Boolean
38
39
40
41
42
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 38
def matches?(job)
@klass = job.is_a?(Class) ? job : job.class
@actual = @klass.get_sidekiq_options[unique_key]
value_matches? && interval_matches? && expiration_matches?
end
|
#until(expiration) ⇒ Object
49
50
51
52
|
# File 'lib/rspec/sidekiq/matchers/be_unique.rb', line 49
def until(expiration)
@expected_expiration = expiration
self
end
|