class RSpec::Core::SharedExampleGroupModule

Represents some functionality that is shared with multiple example groups. The functionality is defined by the provided block, which is lazily eval’d when the ‘SharedExampleGroupModule` instance is included in an example group.

Attributes

Public Class Methods

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 13
def initialize(description, definition, metadata)
  @description = description
  @definition  = definition
  @metadata    = metadata
end

Public Instance Methods

@private

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 34
def include_in(klass, inclusion_line, args, customization_block)
  klass.update_inherited_metadata(@metadata) unless @metadata.empty?

  SharedExampleGroupInclusionStackFrame.with_frame(@description, inclusion_line) do
    RSpec::Support::WithKeywordsWhenNeeded.class_exec(klass, *args, &@definition)
    klass.class_exec(&customization_block) if customization_block
  end
end

Ruby callback for when a module is included in another module is class. Our definition evaluates the shared group block in the context of the including example group.

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 28
def included(klass)
  inclusion_line = klass.metadata[:location]
  include_in klass, inclusion_line, [], nil
end

Provides a human-readable representation of this module.

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 20
def inspect
  "#<#{self.class.name} #{@description.inspect}>"
end
Also aliased as: to_s
Alias for: inspect