Class: TestLauncher::Frameworks::Implementation::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/test_launcher/frameworks/implementation/test_case.rb

Direct Known Subclasses

Base::TestCase

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:, example: nil) ⇒ TestCase

Returns a new instance of TestCase.



13
14
15
16
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 13

def initialize(file:, example: nil)
  @file = file
  @example = example
end

Instance Attribute Details

#exampleObject (readonly)

Returns the value of attribute example.



7
8
9
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 7

def example
  @example
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 7

def file
  @file
end

Class Method Details

.from_search(file:, query: nil) ⇒ Object



9
10
11
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 9

def self.from_search(file:, query: nil)
  new(file: file, example: query)
end

Instance Method Details

#app_rootObject



26
27
28
29
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 26

def app_root
  path = exploded_path[0...exploded_path.rindex(test_root_folder_name)]
  File.join("/", path)
end

#exploded_pathObject



59
60
61
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 59

def exploded_path
  Pathname.new(file).each_filename.to_a
end

#is_example?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 18

def is_example?
  !example.nil?
end

#mtimeObject



22
23
24
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 22

def mtime
  @mtime ||= File.mtime(file)
end

#relative_test_pathObject



35
36
37
38
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 35

def relative_test_path
  path = exploded_path[exploded_path.rindex(test_root_folder_name)..-1]
  File.join(path)
end

#runnerObject

Raises:

  • (NotImplementedError)


51
52
53
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 51

def runner
  raise NotImplementedError
end

#spring_enabled?Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
49
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 40

def spring_enabled?
  return false if ENV['DISABLE_SPRING']

  [
    "bin/spring",
    "bin/testunit"
  ].any? {|f|
    File.exist?(File.join(app_root, f))
  }
end

#test_rootObject



31
32
33
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 31

def test_root
  File.join(app_root, test_root_folder_name)
end

#test_root_folder_nameObject

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 55

def test_root_folder_name
  raise NotImplementedError
end