Class: M::TestMethod
- Inherits:
-
Struct
- Object
- Struct
- M::TestMethod
- Defined in:
- lib/m/test_method.rb
Overview
Simple data structure for what a test method contains.
Too lazy to make a class for this when it’s really just a bag of data without any behavior.
Includes the name of this method, what line on the file it begins on, and where it ends.
Instance Attribute Summary collapse
-
#end_line ⇒ Object
Returns the value of attribute end_line.
-
#name ⇒ Object
Returns the value of attribute name.
-
#start_line ⇒ Object
Returns the value of attribute start_line.
Class Method Summary collapse
Instance Attribute Details
#end_line ⇒ Object
Returns the value of attribute end_line
11 12 13 |
# File 'lib/m/test_method.rb', line 11 def end_line @end_line end |
#name ⇒ Object
Returns the value of attribute name
11 12 13 |
# File 'lib/m/test_method.rb', line 11 def name @name end |
#start_line ⇒ Object
Returns the value of attribute start_line
11 12 13 |
# File 'lib/m/test_method.rb', line 11 def start_line @start_line end |
Class Method Details
.create(suite_class, test_method) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/m/test_method.rb', line 12 def self.create suite_class, test_method method = suite_class.instance_method test_method # Ruby can find the starting line for us, so pull that out of the array. # Ruby 4.1+ can also provide the ending line. #start_line, end_line = method.source_location.values_at(1, 3) start_line = method.source_location[1] # Ruby < 4.1 can't find the end line. Use a Ripper-derived parser to # determine the ending line. #end_line ||= FinishLine.ending_line_for method end_line = FinishLine.ending_line_for method # Shove the given attributes into a new databag new test_method, start_line, end_line end |