Parent

Methods

Class/Module Index [+]

Quicksearch

RSpec::Core::SharedExampleGroup::Registry

@private

Public Instance Methods

add(context, name, *metadata_args, &block) click to toggle source
# File lib/rspec/core/shared_example_group.rb, line 111
def add(context, name, *metadata_args, &block)
  ensure_block_has_source_location(block) { CallerFilter.first_non_rspec_line }

  if valid_name?(name)
    warn_if_key_taken context, name, block
    shared_example_groups[context][name] = block
  else
    metadata_args.unshift name
  end

  unless metadata_args.empty?
    mod = Module.new
    (class << mod; self; end).__send__(:define_method, :included) do |host|
      host.class_exec(&block)
    end
    RSpec.configuration.include mod, *metadata_args
  end
end
find(lookup_contexts, name) click to toggle source
# File lib/rspec/core/shared_example_group.rb, line 130
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.