123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Core::SharedExampleGroupModule

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Module
Instance Chain:
self, Module
Inherits: Module
  • Object
Defined in: rspec-core/lib/rspec/core/shared_example_group.rb

Overview

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.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(description, definition, metadata) ⇒ SharedExampleGroupModule

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 13

def initialize(description, definition, )
  @description = description
  @definition  = definition
  @metadata    = 
end

Instance Attribute Details

#definition (readonly)

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 11

attr_reader :definition

Instance Method Details

#include_in(klass, inclusion_line, args, customization_block)

This method is for internal use only.
[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 34

def include_in(klass, inclusion_line, args, customization_block)
  klass.(@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

#included(klass)

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.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 28

def included(klass)
  inclusion_line = klass.[:location]
  include_in klass, inclusion_line, [], nil
end

#inspect Also known as: #to_s

Provides a human-readable representation of this module.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 20

def inspect
  "#<#{self.class.name} #{@description.inspect}>"
end

#to_s

Alias for #inspect.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 23

alias to_s inspect