Class: RSpec::Core::Example::ExecutionResult
- Inherits:
-
Object
- Object
- RSpec::Core::Example::ExecutionResult
- 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
-
#exception ⇒ Exception?
The failure, if there was one.
-
#finished_at ⇒ Time
When the example finished.
-
#pending_exception ⇒ Exception?
The exception triggered while executing the pending example.
-
#pending_fixed ⇒ Boolean
For examples tagged with
:pending
, this indicates whether or not it now passes. -
#pending_message ⇒ String?
The reason the example was pending, or nil if the example was not pending.
-
#run_time ⇒ Float
How long the example took in seconds.
-
#started_at ⇒ Time
When the example started.
-
#status ⇒ Symbol
:passed
,:failed
or:pending
.
Instance Method Summary collapse
-
#ensure_timing_set(clock) ⇒ void
private
Populates finished_at and run_time if it has not yet been set.
-
#example_skipped? ⇒ Boolean
Indicates if the example was completely skipped (typically done via
:skip
metadata or theskip
method). - #pending_fixed? ⇒ Boolean
-
#record_finished(status, finished_at) ⇒ void
private
Records the finished status of the example.
Instance Attribute Details
#exception ⇒ Exception?
Returns The failure, if there was one.
560 561 562 |
# File 'lib/rspec/core/example.rb', line 560 def exception @exception end |
#finished_at ⇒ Time
Returns When the example finished.
566 567 568 |
# File 'lib/rspec/core/example.rb', line 566 def finished_at @finished_at end |
#pending_exception ⇒ Exception?
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
.
579 580 581 |
# File 'lib/rspec/core/example.rb', line 579 def pending_exception @pending_exception end |
#pending_fixed ⇒ Boolean
Returns For examples tagged with :pending
,
this indicates whether or not it now passes.
583 584 585 |
# File 'lib/rspec/core/example.rb', line 583 def pending_fixed @pending_fixed end |
#pending_message ⇒ String?
Returns The reason the example was pending, or nil if the example was not pending.
573 574 575 |
# File 'lib/rspec/core/example.rb', line 573 def @pending_message end |
#run_time ⇒ Float
Returns How long the example took in seconds.
569 570 571 |
# File 'lib/rspec/core/example.rb', line 569 def run_time @run_time end |
#started_at ⇒ Time
Returns When the example started.
563 564 565 |
# File 'lib/rspec/core/example.rb', line 563 def started_at @started_at end |
#status ⇒ Symbol
Returns :passed
, :failed
or :pending
.
557 558 559 |
# File 'lib/rspec/core/example.rb', line 557 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
607 608 609 |
# File 'lib/rspec/core/example.rb', line 607 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.
594 595 596 |
# File 'lib/rspec/core/example.rb', line 594 def example_skipped? status == :pending && !pending_exception end |
#pending_fixed? ⇒ Boolean
585 586 587 |
# File 'lib/rspec/core/example.rb', line 585 def pending_fixed? !!pending_fixed 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.
600 601 602 603 |
# File 'lib/rspec/core/example.rb', line 600 def record_finished(status, finished_at) self.status = status calculate_run_time(finished_at) end |