Class: RSpec::Core::SharedExampleGroupModule
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Module
|
|
Instance Chain:
self,
Module
|
|
Inherits: |
Module
|
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
- #definition readonly Internal use only Internal use only
Instance Method Summary
- #include_in(klass, inclusion_line, args, customization_block) Internal use only Internal use only
-
#included(klass)
Ruby callback for when a module is included in another module is class.
-
#inspect
(also: #to_s)
Provides a human-readable representation of this module.
-
#to_s
Alias for #inspect.
Constructor Details
.new(description, definition, metadata) ⇒ SharedExampleGroupModule
# 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.
# 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.
# 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.
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 23
alias to_s inspect