Class: RSpec::Core::SharedExampleGroupModule

Inherits:
Module show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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.

Constant Summary

Constants inherited from Module

Module::DELEGATION_RESERVED_KEYWORDS, Module::DELEGATION_RESERVED_METHOD_NAMES, Module::RUBY_RESERVED_KEYWORDS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Module

#alias_attribute, #anonymous?, #append_features, #as_json, #attr_internal_accessor, #attr_internal_reader, #attr_internal_writer, #blankslate_original_append_features, #delegate, #delegate_missing_to, #deprecate, #infect_an_assertion, #mattr_accessor, #mattr_reader, #mattr_writer, #method_visibility, #module_parent, #module_parent_name, #module_parents, #rake_extension, #redefine_method, #redefine_singleton_method, #remove_possible_method, #remove_possible_singleton_method, #silence_redefinition_of_method, #thread_mattr_accessor, #thread_mattr_reader, #thread_mattr_writer

Methods included from Module::Concerning

#concern, #concerning

Constructor Details

#initialize(description, definition, metadata) ⇒ SharedExampleGroupModule

Returns a new instance of SharedExampleGroupModule.



13
14
15
16
17
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/shared_example_group.rb', line 13

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

Instance Attribute Details

#definitionObject (readonly)



11
12
13
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/shared_example_group.rb', line 11

def definition
  @definition
end

Instance Method Details

#include_in(klass, inclusion_line, args, customization_block) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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) ⇒ Object

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.



28
29
30
31
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/shared_example_group.rb', line 28

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

#inspectObject Also known as: to_s

Provides a human-readable representation of this module.



20
21
22
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/shared_example_group.rb', line 20

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