Class/Module Index [+]

Quicksearch

RSpec::Core::SharedExampleGroup

Public Class Methods

created_from_caller(other_caller) click to toggle source
# File lib/rspec/core/shared_example_group.rb, line 36
def self.created_from_caller(other_caller)
  @caller_line == other_caller.last
end
included(kls) click to toggle source
# File lib/rspec/core/shared_example_group.rb, line 40
def self.included(kls)
  kls.describe(&@shared_block)
  kls.children.first.metadata[:shared_group_name] = name
end

Public Instance Methods

share_as(name, &block) click to toggle source
# File lib/rspec/core/shared_example_group.rb, line 26
def share_as(name, &block)
  if Object.const_defined?(name)
    mod = Object.const_get(name)
    raise_name_error unless mod.created_from_caller(caller)
  end

  mod = Module.new do
    @shared_block = block
    @caller_line = caller.last

    def self.created_from_caller(other_caller)
      @caller_line == other_caller.last
    end

    def self.included(kls)
      kls.describe(&@shared_block)
      kls.children.first.metadata[:shared_group_name] = name
    end
  end

  shared_const = Object.const_set(name, mod)
  RSpec.world.shared_example_groups[shared_const] = block
end
share_examples_for(*args, &block) click to toggle source
Alias for: shared_context
shared_context(*args, &block) click to toggle source
# File lib/rspec/core/shared_example_group.rb, line 5
def shared_context(*args, &block)
  if String === args.first || Symbol === args.first
    name = args.shift
    ensure_shared_example_group_name_not_taken(name)
    RSpec.world.shared_example_groups[name] = block
  end

  unless args.empty?
    mod = Module.new
    (class << mod; self; end).send(:define_method, :extended) do |host|
      host.class_eval(&block)
    end
    RSpec.configuration.extend(mod, *args)
  else
  end
end
shared_examples(*args, &block) click to toggle source
Alias for: shared_context
shared_examples_for(*args, &block) click to toggle source
Alias for: shared_context

[Validate]

Generated with the Darkfish Rdoc Generator 2.