Class: RSpec::Core::Example::ExecutionResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/example.rb

Overview

Represents the result of executing an example. Behaves like a hash for backwards compatibility.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exceptionException?

Returns The failure, if there was one.

Returns:

  • (Exception, nil)

    The failure, if there was one.



540
541
542
# File 'lib/rspec/core/example.rb', line 540

def exception
  @exception
end

#finished_atTime

Returns When the example finished.

Returns:

  • (Time)

    When the example finished.



546
547
548
# File 'lib/rspec/core/example.rb', line 546

def finished_at
  @finished_at
end

#pending_exceptionException?

Returns The exception triggered while executing the pending example. If no exception was triggered it would no longer get a status of :pending unless it was tagged with :skip.

Returns:

  • (Exception, nil)

    The exception triggered while executing the pending example. If no exception was triggered it would no longer get a status of :pending unless it was tagged with :skip.



559
560
561
# File 'lib/rspec/core/example.rb', line 559

def pending_exception
  @pending_exception
end

#pending_fixedBoolean Also known as: pending_fixed?

Returns For examples tagged with :pending, this indicates whether or not it now passes.

Returns:

  • (Boolean)

    For examples tagged with :pending, this indicates whether or not it now passes.



563
564
565
# File 'lib/rspec/core/example.rb', line 563

def pending_fixed
  @pending_fixed
end

#pending_messageString?

Returns The reason the example was pending, or nil if the example was not pending.

Returns:

  • (String, nil)

    The reason the example was pending, or nil if the example was not pending.



553
554
555
# File 'lib/rspec/core/example.rb', line 553

def pending_message
  @pending_message
end

#run_timeFloat

Returns How long the example took in seconds.

Returns:

  • (Float)

    How long the example took in seconds.



549
550
551
# File 'lib/rspec/core/example.rb', line 549

def run_time
  @run_time
end

#started_atTime

Returns When the example started.

Returns:

  • (Time)

    When the example started.



543
544
545
# File 'lib/rspec/core/example.rb', line 543

def started_at
  @started_at
end

#statusSymbol

Returns :passed, :failed or :pending.

Returns:

  • (Symbol)

    :passed, :failed or :pending.



537
538
539
# File 'lib/rspec/core/example.rb', line 537

def status
  @status
end

Instance Method Details

#ensure_timing_set(clock) ⇒ void

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.

Populates finished_at and run_time if it has not yet been set



585
586
587
# File 'lib/rspec/core/example.rb', line 585

def ensure_timing_set(clock)
  calculate_run_time(clock.now) unless finished_at
end

#example_skipped?Boolean

Returns Indicates if the example was completely skipped (typically done via :skip metadata or the skip method). Skipped examples will have a :pending result. A :pending result can also come from examples that were marked as :pending, which causes them to be run, and produces a :failed result if the example passes.

Returns:

  • (Boolean)

    Indicates if the example was completely skipped (typically done via :skip metadata or the skip method). Skipped examples will have a :pending result. A :pending result can also come from examples that were marked as :pending, which causes them to be run, and produces a :failed result if the example passes.



572
573
574
# File 'lib/rspec/core/example.rb', line 572

def example_skipped?
  status == :pending && !pending_exception
end

#record_finished(status, finished_at) ⇒ void

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.

Records the finished status of the example.



578
579
580
581
# File 'lib/rspec/core/example.rb', line 578

def record_finished(status, finished_at)
  self.status = status
  calculate_run_time(finished_at)
end