123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Core::SharedExampleGroupInclusionStackFrame

Relationships & Source Files
Inherits: Object
Defined in: rspec-core/lib/rspec/core/example_group.rb

Overview

Contains information about the inclusion site of a shared example group.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.current_backtrace

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/example_group.rb', line 811

def self.current_backtrace
  shared_example_group_inclusions.reverse
end

.shared_example_group_inclusions

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/example_group.rb', line 829

def self.shared_example_group_inclusions
  RSpec::Support.thread_local_data[:shared_example_group_inclusions] ||= []
end

.with_frame(name, location)

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/example_group.rb', line 816

def self.with_frame(name, location)
  current_stack = shared_example_group_inclusions
  if current_stack.any? { |frame| frame.shared_group_name == name }
    raise ArgumentError, "can't include shared examples recursively"
  else
    current_stack << new(name, location)
    yield
  end
ensure
  current_stack.pop
end

Instance Attribute Details

#inclusion_locationString (readonly)

Returns:

  • (String)

    the location where the shared example was included

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/example_group.rb', line 786

attr_reader :inclusion_location

#shared_group_nameString (readonly)

Returns:

  • (String)

    the name of the shared example group

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/example_group.rb', line 784

attr_reader :shared_group_name

Instance Method Details

#descriptionString

Returns:

  • (String)

    Description of this stack frame, in the form used by RSpec’s built-in formatters.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/example_group.rb', line 805

def description
  @description ||= "Shared Example Group: #{shared_group_name.inspect} " \
    "called from #{formatted_inclusion_location}"
end

#formatted_inclusion_locationString

Returns:

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/example_group.rb', line 795

def formatted_inclusion_location
  @formatted_inclusion_location ||= begin
    RSpec.configuration.backtrace_formatter.backtrace_line(
      inclusion_location.sub(/(:\d+):in .+$/, '\1')
    )
  end
end