Class: Minitest::Queue::SingleExample

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runnable, method_name) ⇒ SingleExample

Returns a new instance of SingleExample.



320
321
322
323
# File 'lib/minitest/queue.rb', line 320

def initialize(runnable, method_name)
  @runnable = runnable
  @method_name = method_name
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



318
319
320
# File 'lib/minitest/queue.rb', line 318

def method_name
  @method_name
end

#runnableObject (readonly)

Returns the value of attribute runnable.



318
319
320
# File 'lib/minitest/queue.rb', line 318

def runnable
  @runnable
end

Instance Method Details

#<=>(other) ⇒ Object



333
334
335
# File 'lib/minitest/queue.rb', line 333

def <=>(other)
  id <=> other.id
end

#flaky?Boolean

Returns:



354
355
356
# File 'lib/minitest/queue.rb', line 354

def flaky?
  Minitest.queue.flaky?(self)
end

#idObject



325
326
327
# File 'lib/minitest/queue.rb', line 325

def id
  @id ||= "#{@runnable}##{@method_name}".freeze
end

#queue_entryObject



329
330
331
# File 'lib/minitest/queue.rb', line 329

def queue_entry
  id
end

#runObject



348
349
350
351
352
# File 'lib/minitest/queue.rb', line 348

def run
  with_timestamps do
    Minitest.run_one_method(@runnable, @method_name)
  end
end

#source_locationObject



358
359
360
361
362
# File 'lib/minitest/queue.rb', line 358

def source_location
  @runnable.instance_method(@method_name).source_location
rescue NameError, NoMethodError
  nil
end

#with_timestampsObject



337
338
339
340
341
342
343
344
345
346
# File 'lib/minitest/queue.rb', line 337

def with_timestamps
  start_timestamp = current_timestamp
  result = yield
  result
ensure
  if result
    result.start_timestamp = start_timestamp
    result.finish_timestamp = current_timestamp
  end
end