class RSpec::Core::SharedExampleGroup::Registry

@private

Public Instance Methods

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 150
def add(context, name, *metadata_args, &block)
  unless block
    RSpec.warning "Shared example group #{name} was defined without a "\
                  "block and will have no effect. Please define a "\
                  "block or remove the definition."
  end

  if RSpec.configuration.shared_context_metadata_behavior == :trigger_inclusion
    return legacy_add(context, name, *metadata_args, &block)
  end

  unless valid_name?(name)
    raise ArgumentError, "Shared example group names can only be a string, " \
                         "symbol or module but got: #{name.inspect}"
  end

  ensure_block_has_source_location(block) { CallerFilter.first_non_rspec_line }
  warn_if_key_taken context, name, block

  metadata = Metadata.build_hash_from(metadata_args)
  shared_module = SharedExampleGroupModule.new(name, block, metadata)
  shared_example_groups[context][name] = shared_module
end
# File rspec-core/lib/rspec/core/shared_example_group.rb, line 174
def find(lookup_contexts, name)
  lookup_contexts.each do |context|
    found = shared_example_groups[context][name]
    return found if found
  end

  shared_example_groups[:main][name]
end