class Attestify::TestList::TestClassSourceLocations
Helper class to keep track of source locations of methods for tests.
Public Class Methods
new(test_class)
click to toggle source
# File lib/attestify/test_list.rb, line 94 def initialize(test_class) @test_class = test_class end
Public Instance Methods
in_method?(method, line)
click to toggle source
# File lib/attestify/test_list.rb, line 102 def in_method?(method, line) method_at(line) == method end
real_file(method)
click to toggle source
# File lib/attestify/test_list.rb, line 98 def real_file(method) real_source_locations[method].first end
Private Instance Methods
method_at(line)
click to toggle source
# File lib/attestify/test_list.rb, line 108 def method_at(line) result = nil runnable_method_lines.each do |source_location| return result if source_location.last > line result = source_location.first end result end
real_source_locations()
click to toggle source
# File lib/attestify/test_list.rb, line 135 def real_source_locations @real_source_locations ||= Hash.new do |hash, method| hash[method] = @test_class.instance_method(method).source_location.tap do |result| result[0] = File.realpath(result[0]) end end end
runnable_method_lines()
click to toggle source
# File lib/attestify/test_list.rb, line 123 def runnable_method_lines @runnable_method_lines ||= runnable_methods.map do |runnable_method| [runnable_method] + real_source_locations[runnable_method] end.sort do |a, b| # rubocop:disable Style/MultilineBlockChain if a != b a.last <=> b.last else a.first <=> b.first end end end
runnable_methods()
click to toggle source
# File lib/attestify/test_list.rb, line 119 def runnable_methods @runnable_methods ||= @test_class.runnable_methods end