Module: RSpec

### Home Classes Methods

### In Files

- lib/rspec/core.rb
- lib/rspec/core/backport_random.rb
- lib/rspec/core/backtrace_formatter.rb
- lib/rspec/core/configuration.rb
- lib/rspec/core/configuration_options.rb
- lib/rspec/core/drb.rb
- lib/rspec/core/dsl.rb
- lib/rspec/core/example.rb
- lib/rspec/core/example_group.rb
- lib/rspec/core/filter_manager.rb
- lib/rspec/core/flat_map.rb
- lib/rspec/core/formatters/base_formatter.rb
- lib/rspec/core/formatters/base_text_formatter.rb
- lib/rspec/core/formatters/console_codes.rb
- lib/rspec/core/formatters/deprecation_formatter.rb
- lib/rspec/core/formatters/documentation_formatter.rb
- lib/rspec/core/formatters/helpers.rb
- lib/rspec/core/formatters/html_formatter.rb
- lib/rspec/core/formatters/html_printer.rb
- lib/rspec/core/formatters/json_formatter.rb
- lib/rspec/core/formatters/profile_formatter.rb
- lib/rspec/core/formatters/progress_formatter.rb
- lib/rspec/core/formatters/protocol.rb
- lib/rspec/core/formatters/snippet_extractor.rb
- lib/rspec/core/hooks.rb
- lib/rspec/core/memoized_helpers.rb
- lib/rspec/core/metadata.rb
- lib/rspec/core/metadata_filter.rb
- lib/rspec/core/minitest_assertions_adapter.rb
- lib/rspec/core/mocking_adapters/flexmock.rb
- lib/rspec/core/mocking_adapters/mocha.rb
- lib/rspec/core/mocking_adapters/null.rb
- lib/rspec/core/mocking_adapters/rr.rb
- lib/rspec/core/mocking_adapters/rspec.rb
- lib/rspec/core/ordering.rb
- lib/rspec/core/pending.rb
- lib/rspec/core/project_initializer.rb
- lib/rspec/core/rake_task.rb
- lib/rspec/core/ruby_project.rb
- lib/rspec/core/runner.rb
- lib/rspec/core/sandbox.rb
- lib/rspec/core/shared_context.rb
- lib/rspec/core/shared_example_group.rb
- lib/rspec/core/test_unit_assertions_adapter.rb
- lib/rspec/core/version.rb
- lib/rspec/core/warnings.rb
- lib/rspec/core/world.rb

### Namespace

- MODULE RSpec::Core
- MODULE RSpec::ExampleGroups

### Methods

- ::clear_examples
- ::configuration
- ::configure
- ::const_missing
- ::current_example
- ::current_example=
- ::reset
- ::thread_local_metadata
- ::world

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::AnonymousExampleGroup
- RSpec::Core::Backports
- RSpec::Core::Backports::Random
- RSpec::Core::Backports::Random::Implementation
- RSpec::Core::Backports::Random::MT19937
- RSpec::Core::BacktraceFormatter
- RSpec::Core::Configuration
- RSpec::Core::Configuration::DeprecationReporterBuffer
- RSpec::Core::Configuration::ExposeCurrentExample
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::DRbOptions
- RSpec::Core::DRbRunner
- RSpec::Core::DSL
- RSpec::Core::DSL::RSpec
- RSpec::Core::Example
- RSpec::Core::Example::ExecutionResult
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::ExclusionRules
- RSpec::Core::FilterManager
- RSpec::Core::FilterRules
- RSpec::Core::FilterableItemRepository
- RSpec::Core::FilterableItemRepository::QueryOptimized
- RSpec::Core::FilterableItemRepository::UpdateOptimized
- RSpec::Core::FlatMap
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::ConsoleCodes
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DeprecationFormatter::DelayedPrinter
- RSpec::Core::Formatters::DeprecationFormatter::FileStream
- RSpec::Core::Formatters::DeprecationFormatter::ImmediatePrinter
- RSpec::Core::Formatters::DeprecationFormatter::RaiseErrorStream
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::Loader
- RSpec::Core::Formatters::ProfileFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::Protocol
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::CoderayConverter
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::HashImitatable
- RSpec::Core::HashImitatable::ClassMethods
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterContextHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollections
- RSpec::Core::InclusionRules
- RSpec::Core::LegacyExampleGroupHash
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::MemoizedHelpers::ContextHookMemoizedHash
- RSpec::Core::MemoizedHelpers::ContextHookMemoizedHash::After
- RSpec::Core::MemoizedHelpers::ContextHookMemoizedHash::Before
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleGroupHash
- RSpec::Core::Metadata::ExampleHash
- RSpec::Core::Metadata::HashPopulator
- RSpec::Core::MetadataFilter
- RSpec::Core::MinitestAssertionsAdapter
- RSpec::Core::MockingAdapters
- RSpec::Core::MockingAdapters::Flexmock
- RSpec::Core::MockingAdapters::Mocha
- RSpec::Core::MockingAdapters::Null
- RSpec::Core::MockingAdapters::RR
- RSpec::Core::MockingAdapters::RSpec
- RSpec::Core::Notifications
- RSpec::Core::Notifications::DeprecationNotification
- RSpec::Core::Notifications::ExampleNotification
- RSpec::Core::Notifications::ExamplesNotification
- RSpec::Core::Notifications::FailedExampleNotification
- RSpec::Core::Notifications::NullColorizer
- RSpec::Core::Notifications::NullNotification
- RSpec::Core::Notifications::PendingExampleFailedAsExpectedNotification
- RSpec::Core::Notifications::PendingExampleFixedNotification
- RSpec::Core::Notifications::PendingExampleNotificationMethods
- RSpec::Core::Notifications::ProfileNotification
- RSpec::Core::Notifications::SeedNotification
- RSpec::Core::Notifications::SkippedExampleNotification
- RSpec::Core::Notifications::SummaryNotification
- RSpec::Core::NullReporter
- RSpec::Core::Ordering
- RSpec::Core::Ordering::ConfigurationManager
- RSpec::Core::Ordering::Custom
- RSpec::Core::Ordering::Identity
- RSpec::Core::Ordering::Random
- RSpec::Core::Ordering::Registry
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::Pending::SkipDeclaredInExample
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::RandomNumberGenerator
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::Sandbox
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::SharedExampleGroupInclusionStackFrame
- RSpec::Core::SharedExampleGroupModule
- RSpec::Core::SuiteHookContext
- RSpec::Core::TestUnitAssertionsAdapter
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::Warnings
- RSpec::Core::World
- RSpec::ExampleGroups
- Object

No matching classes.

# RSpec

Namespace for all core RSpec code.

This is borrowed (slightly modified) from Scott Taylor's project_path project:

    http://github.com/smtlaissezfaire/project_path

### Constants

MODULES_TO_AUTOLOAD

  @private

SharedContext

  @private

### Attributes

configuration[W]

Setters for shared global objects @api private

world[W]

Setters for shared global objects @api private

### Public Class Methods

clear_examples() click to toggle source

Used to ensure examples get reloaded between multiple runs in the same process and ensures user configuration is persisted.

Users must invoke this if they want to clear all examples but preserve current configuration when they use the runner multiple times within the same process.

    # File lib/rspec/core.rb, line 69
    def self.clear_examples
      world.reset
      configuration.reporter.reset
      configuration.start_time = ::RSpec::Core::Time.now
      configuration.reset_filters
    end

configuration() click to toggle source

Returns the global [Configuration](RSpec/Core/Configuration) object. While you can use this method to access the configuration, the more common convention is to use [RSpec.configure](RSpec#configure-class_method).

@example

    RSpec.configuration.drb_port = 1234

@see RSpec.configure @see Core::Configuration

    # File lib/rspec/core.rb, line 84
    def self.configuration
      @configuration ||= begin
                           config = RSpec::Core::Configuration.new
                           config.expose_dsl_globally = true
                           config
                         end
    end

configure() click to toggle source

Yields the global configuration to a block. @yield [Configuration] global configuration

@example

    RSpec.configure do |config|
      config.add_formatter 'documentation'
    end

@see Core::Configuration

    # File lib/rspec/core.rb, line 100
    def self.configure
      yield configuration if block_given?
    end

const_missing(name) click to toggle source

@private

    # File lib/rspec/core.rb, line 174
    def self.const_missing(name)
      # Load rspec-expectations when RSpec::Matchers is referenced. This allows
      # people to define custom matchers (using `RSpec::Matchers.define`) before
      # rspec-core has loaded rspec-expectations (since it delays the loading of
      # it to allow users to configure a different assertion/expectation
      # framework). `autoload` can't be used since it works with ruby's built-in
      # require (e.g. for files that are available relative to a load path dir),
      # but not with rubygems' extended require.
      #
      # As of rspec 2.14.1, we no longer require `rspec/mocks` and
      # `rspec/expectations` when `rspec` is required, so we want
      # to make them available as an autoload.
      require MODULES_TO_AUTOLOAD.fetch(name) { return super }
      ::RSpec.const_get(name)
    end

current_example() click to toggle source

The example being executed.

The primary audience for this method is library authors who need access to the example currently being executed and also want to support all versions of RSpec 2 and 3.

@example

    RSpec.configure do |c|
      # context.example is deprecated, but RSpec.current_example is not
      # available until RSpec 3.0.
      fetch_current_example = RSpec.respond_to?(:current_example) ?
        proc { RSpec.current_example } : proc { |context| context.example }

      c.before(:example) do
        example = fetch_current_example.call(self)

        # ...
      end
    end

    # File lib/rspec/core.rb, line 125
    def self.current_example
      thread_local_metadata[:current_example]
    end

current_example=(example) click to toggle source

Set the current example being executed. @api private

    # File lib/rspec/core.rb, line 131
    def self.current_example=(example)
      thread_local_metadata[:current_example] = example
    end

reset() click to toggle source

Used to ensure examples get reloaded and user configuration gets reset to defaults between multiple runs in the same process.

Users must invoke this if they want to have the configuration reset when they use the runner multiple times within the same process. Users must deal themselves with re-configuration of RSpec before run.

    # File lib/rspec/core.rb, line 58
    def self.reset
      @world = nil
      @configuration = nil
    end

thread_local_metadata() click to toggle source

@private A single thread local variable so we don't excessively pollute that namespace.

    # File lib/rspec/core.rb, line 138
    def self.thread_local_metadata
      Thread.current[:_rspec] ||= { :shared_example_group_inclusions => [] }
    end

world() click to toggle source

@private Internal container for global non-configuration data.

    # File lib/rspec/core.rb, line 144
    def self.world
      @world ||= RSpec::Core::World.new
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.