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.
Class Method Summary collapse
Instance Method Summary collapse
- #app_root ⇒ Object
- #exploded_path ⇒ Object
-
#initialize(file:, example: nil) ⇒ TestCase
constructor
A new instance of TestCase.
- #is_example? ⇒ Boolean
- #mtime ⇒ Object
- #relative_test_path ⇒ Object
- #runner ⇒ Object
- #spring_enabled? ⇒ Boolean
- #test_root ⇒ Object
- #test_root_folder_name ⇒ Object
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
#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 |
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_root ⇒ Object
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_path ⇒ Object
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
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_test_path ⇒ Object
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 |
#runner ⇒ Object
51 52 53 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 51 def runner raise NotImplementedError end |
#spring_enabled? ⇒ 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_root ⇒ Object
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_name ⇒ Object
55 56 57 |
# File 'lib/test_launcher/frameworks/implementation/test_case.rb', line 55 def test_root_folder_name raise NotImplementedError end |