Class: RSpecParser
- Inherits:
-
Object
- Object
- RSpecParser
- Defined in:
- lib/files/RSpecParser.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#test_cases ⇒ Object
readonly
Returns the value of attribute test_cases.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#dump_ast ⇒ Object
Prints to standard out the full, unvarnished abstract syntax tree in all it’s ugliness.
-
#initialize(file_name) ⇒ RSpecParser
constructor
A new instance of RSpecParser.
-
#inspect ⇒ Object
Prints to standard out the test cases that were generated by parsing the file.
-
#parse(verbosity: false) ⇒ Object
Performs the parsing of the rspec file and generates an array of TestCase instances.
Constructor Details
#initialize(file_name) ⇒ RSpecParser
Returns a new instance of RSpecParser.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/files/RSpecParser.rb', line 20 def initialize(file_name) file = file_name @top_node = Parser::CurrentRuby.parse_file(file) @ids = [] = {} @skips = [] test_cases = [] @skips_in_before = [] @condition_set = false @indent_amount = " " @in_testrail_id = false end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
18 19 20 |
# File 'lib/files/RSpecParser.rb', line 18 def file @file end |
#test_cases ⇒ Object (readonly)
Returns the value of attribute test_cases.
18 19 20 |
# File 'lib/files/RSpecParser.rb', line 18 def test_cases @test_cases end |
#verbose ⇒ Object
Returns the value of attribute verbose.
19 20 21 |
# File 'lib/files/RSpecParser.rb', line 19 def verbose @verbose end |
Instance Method Details
#dump_ast ⇒ Object
Prints to standard out the full, unvarnished abstract syntax tree in all it’s ugliness.
53 54 55 56 |
# File 'lib/files/RSpecParser.rb', line 53 def dump_ast print_ast(@top_node, "") puts "" end |
#inspect ⇒ Object
Prints to standard out the test cases that were generated by parsing the file
46 47 48 49 50 |
# File 'lib/files/RSpecParser.rb', line 46 def inspect test_cases.each do |tc| puts tc.print end end |
#parse(verbosity: false) ⇒ Object
Performs the parsing of the rspec file and generates an array of TestCase instances
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/files/RSpecParser.rb', line 34 def parse(verbosity:false) verbose = verbosity traverse(@top_node, "") # get the last one added to the array test_cases << @current_test_case.clone test_cases.each do |tc| tc.skip += @skips_in_before end puts "" if verbose end |