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.

Public Class Methods

new(description, definition) click to toggle source
# File lib/rspec/core/shared_example_group.rb, line 8
def initialize(description, definition)
  @description = description
  @definition  = definition
end

Public Instance Methods

included(klass) click to toggle source

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 lib/rspec/core/shared_example_group.rb, line 22
def included(klass)
  inclusion_line = klass.metadata[:location]
  SharedExampleGroupInclusionStackFrame.with_frame(@description, inclusion_line) do
    klass.class_exec(&@definition)
  end
end
inspect() click to toggle source

Provides a human-readable representation of this module.

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