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.
13 14 15 16 17 18 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 13 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.
7 8 9 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 7 def example @example end |
#file ⇒ Object (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 |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
7 8 9 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 7 def line_number @line_number end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
7 8 9 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 7 def request @request end |
Class Method Details
.from_search(file:, query:, request:) ⇒ Object
9 10 11 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 9 def self.from_search(file:, query:, request:) new(file: file, example: query, request: request) end |
Instance Method Details
#app_root ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 32 def app_root test_dir_parent = nil Pathname.new(file).parent.ascend do |path| if test_dir_parent.nil? && path.basename.to_s == test_root_dir_name test_dir_parent = path.parent.to_s next elsif test_dir_parent.nil? next elsif path.entries.any? { |e| e.to_s.match /Gemfile|gemspec|mix.exs|config.ru/ } return path.to_s end end test_dir_parent || Pathname.new(file).parent.to_s end |
#exploded_path ⇒ Object
57 58 59 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 57 def exploded_path file.split("/") end |
#is_example? ⇒ Boolean
20 21 22 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 20 def is_example? !example.nil? end |
#mtime ⇒ Object
24 25 26 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 24 def mtime @mtime ||= File.mtime(file) end |
#relative_file ⇒ Object
28 29 30 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 28 def relative_file file.sub(/^#{File.join(app_root, '/')}/, '') end |
#test_root ⇒ Object
49 50 51 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 49 def test_root File.join(app_root, test_root_dir_name) end |
#test_root_dir_name ⇒ Object
53 54 55 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 53 def test_root_dir_name raise NotImplementedError end |