123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Core::SharedExampleGroup::TopLevelDSL Private

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: rspec-core/lib/rspec/core/shared_example_group.rb

Overview

Shared examples top level ::RSpec::Core::DSL.

Class Attribute Summary

Class Method Summary

Class Attribute Details

.exposed_globally?Boolean (readonly)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/shared_example_group.rb', line 119

def self.exposed_globally?
  @exposed_globally ||= false
end

Class Method Details

.definitions

[ GitHub ]

  
# 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

.expose_globally!

Adds the top level ::RSpec::Core::DSL methods to Module and the top level binding.

[ GitHub ]

  
# 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

.remove_globally!

Removes the top level ::RSpec::Core::DSL methods to Module and the top level binding.

[ GitHub ]

  
# 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