Class: RSpec::Sidekiq::Matchers::HaveEnqueuedJob
- Inherits:
-
Object
- Object
- RSpec::Sidekiq::Matchers::HaveEnqueuedJob
- Defined in:
- lib/rspec/sidekiq/matchers/have_enqueued_job.rb
Instance Attribute Summary collapse
-
#actual_arguments ⇒ Object
readonly
Returns the value of attribute actual_arguments.
-
#actual_options ⇒ Object
readonly
Returns the value of attribute actual_options.
-
#expected_arguments ⇒ Object
readonly
Returns the value of attribute expected_arguments.
-
#expected_options ⇒ Object
readonly
Returns the value of attribute expected_options.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #at(timestamp) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #in(interval) ⇒ Object
-
#initialize(expected_arguments) ⇒ HaveEnqueuedJob
constructor
A new instance of HaveEnqueuedJob.
- #matches?(klass) ⇒ Boolean
Constructor Details
#initialize(expected_arguments) ⇒ HaveEnqueuedJob
Returns a new instance of HaveEnqueuedJob.
92 93 94 95 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 92 def initialize(expected_arguments) @expected_arguments = normalize_arguments(expected_arguments) @expected_options = {} end |
Instance Attribute Details
#actual_arguments ⇒ Object (readonly)
Returns the value of attribute actual_arguments.
90 91 92 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 90 def actual_arguments @actual_arguments end |
#actual_options ⇒ Object (readonly)
Returns the value of attribute actual_options.
90 91 92 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 90 def @actual_options end |
#expected_arguments ⇒ Object (readonly)
Returns the value of attribute expected_arguments.
90 91 92 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 90 def expected_arguments @expected_arguments end |
#expected_options ⇒ Object (readonly)
Returns the value of attribute expected_options.
90 91 92 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 90 def @expected_options end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
90 91 92 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 90 def klass @klass end |
Instance Method Details
#at(timestamp) ⇒ Object
104 105 106 107 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 104 def at() @expected_options['at'] = self end |
#description ⇒ Object
114 115 116 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 114 def description "have an enqueued #{klass} job with arguments #{expected_arguments}" end |
#failure_message ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 118 def = ["expected to have an enqueued #{klass} job"] << " arguments: #{expected_arguments}" if expected_arguments << " options: #{}" if .any? << "found" << " arguments: #{actual_arguments}" if expected_arguments << " options: #{}" if .any? .join("\n") end |
#failure_message_when_negated ⇒ Object
128 129 130 131 132 133 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 128 def = ["expected not to have an enqueued #{klass} job"] << " arguments: #{expected_arguments}" if expected_arguments.any? << " options: #{}" if .any? .join("\n") end |
#in(interval) ⇒ Object
109 110 111 112 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 109 def in(interval) @expected_options['in'] = interval self end |
#matches?(klass) ⇒ Boolean
97 98 99 100 101 102 |
# File 'lib/rspec/sidekiq/matchers/have_enqueued_job.rb', line 97 def matches?(klass) @klass = klass @actual_arguments = unwrapped_job_arguments(klass.jobs) @actual_options = (klass.jobs) JobMatcher.new(klass).present?(expected_arguments, ) end |