Class: RSpec::Core::FilterManager

### Home Classes Methods

### In Files

- lib/rspec/core/filter_manager.rb

### Parent

Object

### Methods

- ::new
- #add_ids
- #add_location
- #empty?
- #exclude
- #exclude_only
- #exclude_with_low_priority
- #include
- #include_only
- #include_with_low_priority
- #prune

### 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::FilterManager

@private

### Attributes

exclusions[R]
inclusions[R]

### Public Class Methods

new() click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 7
    def initialize
      @exclusions, @inclusions = FilterRules.build
    end

### Public Instance Methods

add_ids(rerun_path, scoped_ids) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 22
    def add_ids(rerun_path, scoped_ids)
      # ids is a hash of relative paths to arrays of ids
      # to match against. e.g.
      #   { "./path/to/file.rb" => ["1:1", "2:4"] }
      rerun_path = Metadata.relative_path(File.expand_path rerun_path)
      add_path_to_arrays_filter(:ids, rerun_path, scoped_ids)
    end

add_location(file_path, line_numbers) click to toggle source

@api private

@param file_path [String] @param line_numbers [Array]

    # File lib/rspec/core/filter_manager.rb, line 15
    def add_location(file_path, line_numbers)
      # locations is a hash of expanded paths to arrays of line
      # numbers to match against. e.g.
      #   { "path/to/file.rb" => [37, 42] }
      add_path_to_arrays_filter(:locations, File.expand_path(file_path), line_numbers)
    end

empty?() click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 30
    def empty?
      inclusions.empty? && exclusions.empty?
    end

exclude(*args) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 57
    def exclude(*args)
      exclusions.add(args.last)
    end

exclude_only(*args) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 61
    def exclude_only(*args)
      exclusions.use_only(args.last)
    end

exclude_with_low_priority(*args) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 65
    def exclude_with_low_priority(*args)
      exclusions.add_with_low_priority(args.last)
    end

include(*args) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 69
    def include(*args)
      inclusions.add(args.last)
    end

include_only(*args) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 73
    def include_only(*args)
      inclusions.use_only(args.last)
    end

include_with_low_priority(*args) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 77
    def include_with_low_priority(*args)
      inclusions.add_with_low_priority(args.last)
    end

prune(examples) click to toggle source

    # File lib/rspec/core/filter_manager.rb, line 34
    def prune(examples)
      # Semantically, this is unnecessary (the filtering below will return the empty
      # array unmodified), but for perf reasons it's worth exiting early here. Users
      # commonly have top-level examples groups that do not have any direct examples
      # and instead have nested groups with examples. In that kind of situation,
      # `examples` will be empty.
      return examples if examples.empty?

      examples = prune_conditionally_filtered_examples(examples)

      if inclusions.standalone?
        examples.select { |e| inclusions.include_example?(e) }
      else
        locations, ids, non_scoped_inclusions = inclusions.split_file_scoped_rules

        examples.select do |ex|
          file_scoped_include?(ex.metadata, ids, locations) do
            !exclusions.include_example?(ex) && non_scoped_inclusions.include_example?(ex)
          end
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.