Class: RSpec::Core::World

### Home Classes Methods

### In Files

- lib/rspec/core/world.rb

### Parent

Object

### Methods

- ::new
- #all_example_groups
- #all_examples
- #announce_exclusion_filter
- #announce_filters
- #announce_inclusion_filter
- #everything_filtered_message
- #example_count
- #exclusion_filter
- #filter_manager
- #inclusion_filter
- #num_example_groups_defined_in
- #ordered_example_groups
- #preceding_declaration_line
- #register
- #reporter
- #reset
- #shared_example_group_registry

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::AnonymousExampleGroup
- RSpec::Core::BacktraceFormatter
- RSpec::Core::Bisect
- RSpec::Core::Bisect::Coordinator
- RSpec::Core::Bisect::ExampleMinimizer
- RSpec::Core::Bisect::Runner
- RSpec::Core::Bisect::Server
- RSpec::Core::Bisect::SubsetEnumerator
- 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::ExampleStatusDumper
- RSpec::Core::ExampleStatusMerger
- RSpec::Core::ExampleStatusParser
- RSpec::Core::ExampleStatusPersister
- 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::BisectDebugFormatter
- RSpec::Core::Formatters::BisectFormatter
- RSpec::Core::Formatters::BisectProgressFormatter
- 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::ExceptionPresenter
- RSpec::Core::Formatters::ExceptionPresenter::Factory
- RSpec::Core::Formatters::ExceptionPresenter::Factory::CommonBacktraceTruncater
- RSpec::Core::Formatters::ExceptionPresenter::Factory::EmptyBacktraceFormatter
- RSpec::Core::Formatters::FallbackMessageFormatter
- 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::ContextHookMemoized
- RSpec::Core::MemoizedHelpers::ContextHookMemoized::After
- RSpec::Core::MemoizedHelpers::ContextHookMemoized::Before
- RSpec::Core::MemoizedHelpers::NonThreadSafeMemoized
- RSpec::Core::MemoizedHelpers::ThreadsafeMemoized
- 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::MultipleExceptionError
- RSpec::Core::MultipleExceptionError::InterfaceTag
- RSpec::Core::Mutex
- RSpec::Core::Notifications
- RSpec::Core::Notifications::CustomNotification
- 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::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::Profiler
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::ReentrantMutex
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::Sandbox
- RSpec::Core::Set
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::SharedExampleGroupInclusionStackFrame
- RSpec::Core::SharedExampleGroupModule
- RSpec::Core::ShellEscape
- 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::Core::World

@api private

Internal container for global non-configuration data.

### Attributes

example_groups[R]

@private

filtered_examples[R]

@private

wants_to_quit[RW]

Used internally to determine what to do when a SIGINT is received.

### Public Class Methods

new(configuration=RSpec.configuration) click to toggle source

    # File lib/rspec/core/world.rb, line 13
    def initialize(configuration=RSpec.configuration)
      @configuration = configuration
      @example_groups = []
      @example_group_counts_by_spec_file = Hash.new(0)
      @filtered_examples = Hash.new do |hash, group|
        hash[group] = filter_manager.prune(group.examples)
      end
    end

### Public Instance Methods

all_example_groups() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 81
    def all_example_groups
      FlatMap.flat_map(example_groups) { |g| g.descendants }
    end

all_examples() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 86
    def all_examples
      FlatMap.flat_map(all_example_groups) { |g| g.examples }
    end

announce_exclusion_filter(announcements) click to toggle source

@api private

Add exclusion filters to announcement message.

    # File lib/rspec/core/world.rb, line 155
    def announce_exclusion_filter(announcements)
      return if exclusion_filter.empty?

      announcements << "exclude #{exclusion_filter.description}"
    end

announce_filters() click to toggle source

@api private

Notify reporter of filters.

    # File lib/rspec/core/world.rb, line 107
    def announce_filters
      fail_if_config_and_cli_options_invalid
      filter_announcements = []

      announce_inclusion_filter filter_announcements
      announce_exclusion_filter filter_announcements

      unless filter_manager.empty?
        if filter_announcements.length == 1
          reporter.message("Run options: #{filter_announcements[0]}")
        else
          reporter.message("Run options:\n  #{filter_announcements.join("\n  ")}")
        end
      end

      if @configuration.run_all_when_everything_filtered? && example_count.zero? && !@configuration.only_failures?
        reporter.message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}")
        filtered_examples.clear
        inclusion_filter.clear
      end

      return unless example_count.zero?

      example_groups.clear
      if filter_manager.empty?
        reporter.message("No examples found.")
      elsif exclusion_filter.empty? || inclusion_filter.empty?
        reporter.message(everything_filtered_message)
      end
    end

announce_inclusion_filter(announcements) click to toggle source

@api private

Add inclusion filters to announcement message.

    # File lib/rspec/core/world.rb, line 146
    def announce_inclusion_filter(announcements)
      return if inclusion_filter.empty?

      announcements << "include #{inclusion_filter.description}"
    end

everything_filtered_message() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 139
    def everything_filtered_message
      "\nAll examples were filtered out"
    end

example_count(groups=example_groups) click to toggle source

@api private

Get count of examples to be run.

    # File lib/rspec/core/world.rb, line 75
    def example_count(groups=example_groups)
      FlatMap.flat_map(groups) { |g| g.descendants }.
        inject(0) { |a, e| a + e.filtered_examples.size }
    end

exclusion_filter() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 68
    def exclusion_filter
      @configuration.exclusion_filter
    end

filter_manager() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 39
    def filter_manager
      @configuration.filter_manager
    end

inclusion_filter() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 63
    def inclusion_filter
      @configuration.inclusion_filter
    end

num_example_groups_defined_in(file) click to toggle source

@private

    # File lib/rspec/core/world.rb, line 53
    def num_example_groups_defined_in(file)
      @example_group_counts_by_spec_file[file]
    end

ordered_example_groups() click to toggle source

@api private

Apply ordering strategy from configuration to example groups.

    # File lib/rspec/core/world.rb, line 25
    def ordered_example_groups
      ordering_strategy = @configuration.ordering_registry.fetch(:global)
      ordering_strategy.order(@example_groups)
    end

preceding_declaration_line(filter_line) click to toggle source

@api private

Find line number of previous declaration.

    # File lib/rspec/core/world.rb, line 93
    def preceding_declaration_line(filter_line)
      declaration_line_numbers.sort.inject(nil) do |highest_prior_declaration_line, line|
        line <= filter_line ? line : highest_prior_declaration_line
      end
    end

register(example_group) click to toggle source

@api private

Register an example group.

    # File lib/rspec/core/world.rb, line 46
    def register(example_group)
      example_groups << example_group
      @example_group_counts_by_spec_file[example_group.metadata[:file_path]] += 1
      example_group
    end

reporter() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 100
    def reporter
      @configuration.reporter
    end

reset() click to toggle source

@api private

Reset world to 'scratch' before running suite.

    # File lib/rspec/core/world.rb, line 33
    def reset
      example_groups.clear
      @shared_example_group_registry = nil
    end

shared_example_group_registry() click to toggle source

@private

    # File lib/rspec/core/world.rb, line 58
    def shared_example_group_registry
      @shared_example_group_registry ||= SharedExampleGroup::Registry.new
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.