Class: TestLauncher::Frameworks::Implementation::TestCase
- Inherits:
-
Object
- Object
- TestLauncher::Frameworks::Implementation::TestCase
- Defined in:
- lib/test_launcher/frameworks/implementation/test_case.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#example ⇒ Object
readonly
Returns the value of attribute example.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
- #app_root ⇒ Object
- #exploded_path ⇒ Object
-
#initialize(file:, example: nil, request:, line_number: nil) ⇒ TestCase
constructor
A new instance of TestCase.
- #is_example? ⇒ Boolean
- #mtime ⇒ Object
- #relative_file ⇒ Object
- #test_root ⇒ Object
- #test_root_dir_name ⇒ Object
Constructor Details
#initialize(file:, example: nil, request:, line_number: nil) ⇒ TestCase
Returns a new instance of TestCase.
11 12 13 14 15 16 |
# 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 |
Instance Attribute Details
#example ⇒ Object (readonly)
Returns the value of attribute example.
5 6 7 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 5 def example @example end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 5 def file @file end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
5 6 7 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 5 def line_number @line_number end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
5 6 7 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 5 def request @request end |
Class Method Details
.from_search(file:, query:, request:) ⇒ Object
7 8 9 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 7 def self.from_search(file:, query:, request:) new(file: file, example: query, request: request) end |
Instance Method Details
#app_root ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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 ⇒ Object
56 57 58 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 56 def exploded_path file.split("/") end |
#is_example? ⇒ Boolean
18 19 20 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 18 def is_example? !example.nil? end |
#mtime ⇒ Object
22 23 24 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 22 def mtime @mtime ||= File.mtime(file) end |
#relative_file ⇒ Object
26 27 28 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 26 def relative_file file.sub(/^#{File.join(app_root, '/')}/, '') end |
#test_root ⇒ Object
48 49 50 |
# 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 ⇒ Object
52 53 54 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 52 def test_root_dir_name raise NotImplementedError end |