class TestLauncher::Frameworks::Implementation::TestCase

Attributes

example[R]
file[R]
line_number[R]
request[R]

Public Class Methods

new(file:, example: nil, request:, line_number: nil) click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 11
def initialize(file:, example: nil, request:, line_number: nil)
  @file = file
  @example = example
  @line_number = line_number
  @request = request
end

Public Instance Methods

app_root() click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 30
def app_root
  if exploded_path.select { |dir| dir == test_root_dir_name }.size > 1
    candidates = exploded_path

    while !candidates.empty?
      if candidates.last == test_root_dir_name
        root_path = File.join("/", candidates[0..-2])
        return root_path if Dir.entries(root_path).any? {|e| e.match /Gemfile|gemspec|mix.exs|config.ru/} # TODO: extract this
      end

      candidates.pop
    end
  end

  path = exploded_path[0...exploded_path.index(test_root_dir_name)]
  File.join("/", path)
end
exploded_path() click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 56
def exploded_path
  file.split("/")
end
is_example?() click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 18
def is_example?
  !example.nil?
end
mtime() click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 22
def mtime
  @mtime ||= File.mtime(file)
end
relative_file() click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 26
def relative_file
  file.sub(/^#{File.join(app_root, '/')}/, '')
end
test_root() click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 48
def test_root
  File.join(app_root, test_root_dir_name)
end
test_root_dir_name() click to toggle source
# File lib/test_launcher/frameworks/implementation/test_case.rb, line 52
def test_root_dir_name
  raise NotImplementedError
end