Class: Minitest::Queue::SingleExample
- Inherits:
-
Object
- Object
- Minitest::Queue::SingleExample
- Defined in:
- lib/minitest/queue.rb
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#runnable ⇒ Object
readonly
Returns the value of attribute runnable.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #flaky? ⇒ Boolean
- #id ⇒ Object
-
#initialize(runnable, method_name) ⇒ SingleExample
constructor
A new instance of SingleExample.
- #queue_entry ⇒ Object
- #run ⇒ Object
- #source_location ⇒ Object
- #with_timestamps ⇒ Object
Constructor Details
#initialize(runnable, method_name) ⇒ SingleExample
Returns a new instance of SingleExample.
403 404 405 406 |
# File 'lib/minitest/queue.rb', line 403 def initialize(runnable, method_name) @runnable = runnable @method_name = method_name end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
401 402 403 |
# File 'lib/minitest/queue.rb', line 401 def method_name @method_name end |
#runnable ⇒ Object (readonly)
Returns the value of attribute runnable.
401 402 403 |
# File 'lib/minitest/queue.rb', line 401 def runnable @runnable end |
Instance Method Details
#<=>(other) ⇒ Object
425 426 427 |
# File 'lib/minitest/queue.rb', line 425 def <=>(other) id <=> other.id end |
#flaky? ⇒ Boolean
446 447 448 |
# File 'lib/minitest/queue.rb', line 446 def flaky? Minitest.queue.flaky?(self) end |
#id ⇒ Object
408 409 410 |
# File 'lib/minitest/queue.rb', line 408 def id @id ||= "#{@runnable}##{@method_name}".freeze end |
#queue_entry ⇒ Object
412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/minitest/queue.rb', line 412 def queue_entry @queue_entry ||= begin unless runnable.is_a?(Module) raise ArgumentError, "runnable must be a Module (got #{runnable.class}). " \ "Do not create SingleExample with string class names." end file_path = runnable.instance_method(method_name).source_location&.first raise ArgumentError, "Cannot resolve source file for #{id} — " \ "ensure the test method is defined in a Ruby source file" if file_path.nil? CI::Queue::QueueEntry.format(id, file_path) end end |
#run ⇒ Object
440 441 442 443 444 |
# File 'lib/minitest/queue.rb', line 440 def run do @runnable.new(@method_name).run end end |
#source_location ⇒ Object
450 451 452 453 454 |
# File 'lib/minitest/queue.rb', line 450 def source_location @runnable.instance_method(@method_name).source_location rescue NameError, NoMethodError nil end |
#with_timestamps ⇒ Object
429 430 431 432 433 434 435 436 437 438 |
# File 'lib/minitest/queue.rb', line 429 def = result = yield result ensure if result result. = result. = end end |