module RSpec::Core::SharedExampleGroup::TopLevelDSL

@api private

Shared examples top level DSL.

Public Class Methods

@private

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 108
def self.definitions
  proc do
    def shared_examples(name, *args, &block)
      RSpec.world.shared_example_group_registry.add(:main, name, *args, &block)
    end
    alias shared_context      shared_examples
    alias shared_examples_for shared_examples
  end
end

@api private

Adds the top level DSL methods to Module and the top level binding.

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 126
def self.expose_globally!
  return if exposed_globally?
  Core::DSL.change_global_dsl(&definitions)
  @exposed_globally = true
end

@private

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 119
def self.exposed_globally?
  @exposed_globally ||= false
end

@api private

Removes the top level DSL methods to Module and the top level binding.

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 135
def self.remove_globally!
  return unless exposed_globally?

  Core::DSL.change_global_dsl do
    undef shared_examples
    undef shared_context
    undef shared_examples_for
  end

  @exposed_globally = false
end

Public Instance Methods

# File rspec-core/lib/rspec/core/shared_example_group.rb, line 110
def shared_examples(name, *args, &block)
  RSpec.world.shared_example_group_registry.add(:main, name, *args, &block)
end