Class: Minitest::PathExpander::TM
- Inherits:
-
Data
- Object
- Data
- Minitest::PathExpander::TM
- Defined in:
- lib/minitest/path_expander.rb
Overview
Simple TestMethod (abbr TM) Data object.
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #include?(o) ⇒ Boolean
-
#initialize(klass:, name:) ⇒ TM
constructor
A new instance of TM.
- #line_s ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(klass:, name:) ⇒ TM
Returns a new instance of TM.
390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/minitest/path_expander.rb', line 390 def initialize klass:, name: method = klass.instance_method name path, line_s = method.source_location path = path.delete_prefix "#{Dir.pwd}/" line_e = line_s + TM.source_for(method).lines.size - 1 lines = line_s..line_e super klass:, name:, path:, lines: end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass
389 390 391 |
# File 'lib/minitest/path_expander.rb', line 389 def klass @klass end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines
389 390 391 |
# File 'lib/minitest/path_expander.rb', line 389 def lines @lines end |
#name ⇒ Object (readonly)
Returns the value of attribute name
389 390 391 |
# File 'lib/minitest/path_expander.rb', line 389 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path
389 390 391 |
# File 'lib/minitest/path_expander.rb', line 389 def path @path end |
Class Method Details
.cache ⇒ Object
417 |
# File 'lib/minitest/path_expander.rb', line 417 def self.cache = @cache ||= {} |
.source_for(method) ⇒ Object
403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/minitest/path_expander.rb', line 403 def self.source_for method path, line = method.source_location file = cache[path] ||= File.readlines(path) ruby = +"" file[line-1..].each do |l| ruby << l return ruby if Prism.parse_success? ruby end nil end |
Instance Method Details
#include?(o) ⇒ Boolean
419 |
# File 'lib/minitest/path_expander.rb', line 419 def include?(o) = o.is_a?(Integer) ? lines.include?(o) : lines.overlap?(o) |
#line_s ⇒ Object
423 |
# File 'lib/minitest/path_expander.rb', line 423 def line_s = lines.begin |
#to_s ⇒ Object
421 |
# File 'lib/minitest/path_expander.rb', line 421 def to_s = "%s:%d-%d" % [path, lines.begin, lines.end] |