Class: RSpec::Core::FilterManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFilterManager

Returns a new instance of FilterManager.



7
8
9
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 7

def initialize
  @exclusions, @inclusions = FilterRules.build
end

Instance Attribute Details

#exclusionsObject (readonly)

Returns the value of attribute exclusions.



5
6
7
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 5

def exclusions
  @exclusions
end

#inclusionsObject (readonly)

Returns the value of attribute inclusions.



5
6
7
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 5

def inclusions
  @inclusions
end

Instance Method Details

#add_ids(rerun_path, scoped_ids) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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 = .relative_path(File.expand_path rerun_path)
  add_path_to_arrays_filter(:ids, rerun_path, scoped_ids)
end

#add_location(file_path, line_numbers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



15
16
17
18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 30

def empty?
  inclusions.empty? && exclusions.empty?
end

#exclude(*args) ⇒ Object



57
58
59
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 57

def exclude(*args)
  exclusions.add(args.last)
end

#exclude_only(*args) ⇒ Object



61
62
63
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 61

def exclude_only(*args)
  exclusions.use_only(args.last)
end

#exclude_with_low_priority(*args) ⇒ Object



65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 65

def exclude_with_low_priority(*args)
  exclusions.add_with_low_priority(args.last)
end

#include(*args) ⇒ Object



69
70
71
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 69

def include(*args)
  inclusions.add(args.last)
end

#include_only(*args) ⇒ Object



73
74
75
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 73

def include_only(*args)
  inclusions.use_only(args.last)
end

#include_with_low_priority(*args) ⇒ Object



77
78
79
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/filter_manager.rb', line 77

def include_with_low_priority(*args)
  inclusions.add_with_low_priority(args.last)
end

#prune(examples) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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., ids, locations) do
        !exclusions.include_example?(ex) && non_scoped_inclusions.include_example?(ex)
      end
    end
  end
end