class Attestify::TestList::FileFilter

Filters tests that aren't defined in the provided file. If a line is provided, then only the test defined above that line will not be filtered.

Attributes

file[R]
line[R]

Public Class Methods

new(file, line = nil) click to toggle source
# File lib/attestify/test_list.rb, line 57
def initialize(file, line = nil)
  @file = file
  @line = line
end
with_line(path_with_line) click to toggle source
# File lib/attestify/test_list.rb, line 62
def self.with_line(path_with_line)
  match = /\A(.*):(\d+)\z/.match(path_with_line)
  return unless File.file?(match[1])
  new(match[1], match[2].to_i)
end

Public Instance Methods

run?(test_class, method) click to toggle source
# File lib/attestify/test_list.rb, line 68
def run?(test_class, method)
  file_matches?(test_class, method) && line_matches?(test_class, method)
end

Private Instance Methods

file_matches?(test_class, method) click to toggle source
# File lib/attestify/test_list.rb, line 74
def file_matches?(test_class, method)
  real_file == Attestify::TestList::RealSourceLocationCache[test_class].real_file(method)
end
line_matches?(test_class, method) click to toggle source
# File lib/attestify/test_list.rb, line 78
def line_matches?(test_class, method)
  if line
    Attestify::TestList::RealSourceLocationCache[test_class].in_method?(method, line)
  else
    true
  end
end
real_file() click to toggle source
# File lib/attestify/test_list.rb, line 86
def real_file
  @real_file ||= File.realpath(file)
end