Class: RSpec::Sidekiq::Matchers::Base Private
- Inherits:
-
Object
- Object
- RSpec::Sidekiq::Matchers::Base
- Includes:
- Matchers::Composable, Mocks::ArgumentMatchers
- Defined in:
- lib/rspec/sidekiq/matchers/base.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Attribute Summary collapse
- #actual_jobs ⇒ Object readonly private
- #expected_arguments ⇒ Object readonly private
- #expected_options ⇒ Object readonly private
- #klass ⇒ Object readonly private
Instance Method Summary collapse
- #at(timestamp) ⇒ Object private
- #description ⇒ Object private
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
- #formatted(thing) ⇒ Object private
- #immediately ⇒ Object private
- #in(interval) ⇒ Object private
-
#initialize ⇒ Base
constructor
private
A new instance of Base.
- #normalize_arguments(args) ⇒ Object private
- #on(queue) ⇒ Object private
- #with(*expected_arguments) ⇒ Object private
Constructor Details
#initialize ⇒ Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Base.
169 170 171 172 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 169 def initialize @expected_arguments = [any_args] @expected_options = {} end |
Instance Attribute Details
#actual_jobs ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
167 168 169 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 167 def actual_jobs @actual_jobs end |
#expected_arguments ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
167 168 169 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 167 def expected_arguments @expected_arguments end |
#expected_options ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
167 168 169 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 167 def @expected_options end |
#klass ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
167 168 169 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 167 def klass @klass end |
Instance Method Details
#at(timestamp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
179 180 181 182 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 179 def at() @expected_options["at"] = .to_time.to_i self end |
#description ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
199 200 201 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 199 def description "have an enqueued #{klass} job with arguments #{expected_arguments}" end |
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 203 def = ["expected to have an enqueued #{klass} job"] if expected_arguments << " with arguments:" << " -#{formatted(expected_arguments)}" end if .any? << " with context:" << " -#{formatted()}" end if actual_jobs.any? << "but have enqueued only jobs" if expected_arguments = actual_jobs.map do |job| base = " -JID:#{job.jid} with arguments:" base << "\n -#{formatted(job.args)}" if .any? base << "\n with context: #{formatted(job.context)}" end base end << .join("\n") end end .join("\n") end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
235 236 237 238 239 240 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 235 def = ["expected not to have an enqueued #{klass} job"] << " arguments: #{expected_arguments}" if expected_arguments.any? << " options: #{}" if .any? .join("\n") end |
#formatted(thing) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
242 243 244 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 242 def formatted(thing) RSpec::Support::ObjectFormatter.format(thing) end |
#immediately ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
189 190 191 192 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 189 def immediately @expected_options["at"] = nil self end |
#in(interval) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
184 185 186 187 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 184 def in(interval) @expected_options["at"] = (Time.now.to_f + interval.to_f).to_i self end |
#normalize_arguments(args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 246 def normalize_arguments(args) if args.is_a?(Array) args.map{ |x| normalize_arguments(x) } elsif args.is_a?(Hash) args.each_with_object({}) do |(key, value), hash| hash[key.to_s] = normalize_arguments(value) end elsif args.is_a?(Symbol) args.to_s else args end end |
#on(queue) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
194 195 196 197 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 194 def on(queue) @expected_options["queue"] = queue self end |
#with(*expected_arguments) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
174 175 176 177 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 174 def with(*expected_arguments) @expected_arguments = normalize_arguments(expected_arguments) self end |