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

- (Exception?) exception

Returns The failure, if there was one.

Returns:

  • (Exception, nil)

    The failure, if there was one.

396
397
398
# File 'lib/rspec/core/example.rb', line 396
def exception
  @exception
end

- (Time) finished_at

Returns When the example finished.

Returns:

  • (Time)

    When the example finished.

402
403
404
# File 'lib/rspec/core/example.rb', line 402
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.

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.

415
416
417
# File 'lib/rspec/core/example.rb', line 415
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.

Returns:

  • (Boolean)

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

419
420
421
# File 'lib/rspec/core/example.rb', line 419
def pending_fixed
  @pending_fixed
end

- (String?) pending_message

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.

409
410
411
# File 'lib/rspec/core/example.rb', line 409
def pending_message
  @pending_message
end

- (Float) run_time

Returns How long the example took in seconds.

Returns:

  • (Float)

    How long the example took in seconds.

405
406
407
# File 'lib/rspec/core/example.rb', line 405
def run_time
  @run_time
end

- (Time) started_at

Returns When the example started.

Returns:

  • (Time)

    When the example started.

399
400
401
# File 'lib/rspec/core/example.rb', line 399
def started_at
  @started_at
end

- (Symbol) status

Returns :passed, :failed or :pending.

Returns:

  • (Symbol)

    :passed, :failed or :pending.

393
394
395
# File 'lib/rspec/core/example.rb', line 393
def status
  @status
end

Instance Method Details

- (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.

425
426
427
428
429
# File 'lib/rspec/core/example.rb', line 425
def record_finished(status, finished_at)
  self.status      = status
  self.finished_at = finished_at
  self.run_time    = (finished_at - started_at).to_f
end