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.
-
- (Time) finished_at
When the example finished.
-
- (Exception?) pending_exception
The exception triggered while executing the pending example.
-
- (Boolean) pending_fixed
(also: #pending_fixed?)
For examples tagged with
:pending
, this indicates whether or not it now passes. -
- (String?) pending_message
The reason the example was pending, or nil if the example was not pending.
-
- (Float) run_time
How long the example took in seconds.
-
- (Time) started_at
When the example started.
-
- (Symbol) status
:passed
,:failed
or:pending
.
Instance Method Summary (collapse)
-
- (Boolean) example_skipped?
Indicates if the example was completely skipped (typically done via
:skip
metadata or theskip
method). -
- (void) record_finished(status, finished_at)
private
Records the finished status of the example.
Instance Attribute Details
- (Exception?) exception
Returns The failure, if there was one.
451 452 453 |
# File 'lib/rspec/core/example.rb', line 451 def exception @exception end |
- (Time) finished_at
Returns When the example finished.
457 458 459 |
# File 'lib/rspec/core/example.rb', line 457 def finished_at @finished_at end |
- (Exception?) pending_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
.
470 471 472 |
# File 'lib/rspec/core/example.rb', line 470 def pending_exception @pending_exception end |
- (Boolean) pending_fixed Also known as: pending_fixed?
Returns For examples tagged with :pending
,
this indicates whether or not it now passes.
474 475 476 |
# File 'lib/rspec/core/example.rb', line 474 def pending_fixed @pending_fixed end |
- (String?) pending_message
Returns The reason the example was pending, or nil if the example was not pending.
464 465 466 |
# File 'lib/rspec/core/example.rb', line 464 def @pending_message end |
- (Float) run_time
Returns How long the example took in seconds.
460 461 462 |
# File 'lib/rspec/core/example.rb', line 460 def run_time @run_time end |
- (Time) started_at
Returns When the example started.
454 455 456 |
# File 'lib/rspec/core/example.rb', line 454 def started_at @started_at end |
- (Symbol) status
Returns :passed
, :failed
or :pending
.
448 449 450 |
# File 'lib/rspec/core/example.rb', line 448 def status @status end |
Instance Method Details
- (Boolean) example_skipped?
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.
483 484 485 |
# File 'lib/rspec/core/example.rb', line 483 def example_skipped? status == :pending && !pending_exception end |
- (void) record_finished(status, finished_at)
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.
489 490 491 492 493 |
# File 'lib/rspec/core/example.rb', line 489 def record_finished(status, finished_at) self.status = status self.finished_at = finished_at self.run_time = (finished_at - started_at).to_f end |