RSpec

Library providing tools for writing and running RSpec tests.

Module: RSpec::SleepingKingStudios::Deferred

Parent Namespace
RSpec::SleepingKingStudios
Defined In
lib/rspec/sleeping_king_studios/deferred.rb

Table Of Contents

Overview

Namespace for deferred example functionality.

Back To Top

Defined Under Namespace

Classes
Call
Modules
Calls, Consumer, Definitions, Dependencies, Dsl, Examples, Missing, Provider

Back To Top

Class Methods

.reflect(example, source_locations: false) => String

Returns the full path of an example, including deferred example groups.

By default, returns the path in a single-line format similar to an example group description. Deferred example groups are parenthesized. When the :source_locations flag is set to true, it instead returns each example group or deferred group on its own line, along with the source location for that group.

Examples

Displaying the full path of failing specs:

config.after(:example) do |example|
  next unless ENV['REFLECT_ON_FAILURE']
  next unless example.metadata[:last_run_status] == 'failed'

  STDERR.puts "\nFailing spec at:"

  path =
    RSpec::SleepingKingStudios::Deferred
      .reflect(example, source_locations: true)
  path =
    SleepingKingStudios::Tools::Toolbelt
      .instance
      .string_tools
      .indent(path)

  STDERR.puts path
end

Parameters

Returns

Back To Top


Back to Documentation | Versions | 2.8 | Reference | RSpec | RSpec::SleepingKingStudios