123456789_123456789_123456789_123456789_123456789_

Class: Rails::TestUnit::CompositeFilter

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: railties/lib/rails/test_unit/runner.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(runnable, filter, patterns) ⇒ CompositeFilter

[ GitHub ]

  
# File 'railties/lib/rails/test_unit/runner.rb', line 150

def initialize(runnable, filter, patterns)
  @runnable = runnable
  @named_filter = derive_named_filter(filter)
  @filters = [ @named_filter, *derive_line_filters(patterns) ].compact
end

Instance Attribute Details

#named_filter (readonly)

[ GitHub ]

  
# File 'railties/lib/rails/test_unit/runner.rb', line 148

attr_reader :named_filter

Instance Method Details

#===(method)

minitest uses === to find matching filters.

[ GitHub ]

  
# File 'railties/lib/rails/test_unit/runner.rb', line 157

def ===(method)
  @filters.any? { |filter| filter === method }
end

#derive_line_filters(patterns) (private)

[ GitHub ]

  
# File 'railties/lib/rails/test_unit/runner.rb', line 172

def derive_line_filters(patterns)
  patterns.flat_map do |file, lines|
    if lines.empty?
      Filter.new(@runnable, file, nil) if file
    else
      lines.map { |line| Filter.new(@runnable, file, line) }
    end
  end
end

#derive_named_filter(filter) (private)

[ GitHub ]

  
# File 'railties/lib/rails/test_unit/runner.rb', line 162

def derive_named_filter(filter)
  if filter.respond_to?(:named_filter)
    filter.named_filter
  elsif filter =~ %r%/(.*)/% # Regexp filtering copied from minitest.
    Regexp.new $1
  elsif filter.is_a?(String)
    filter
  end
end