class OnlyofficeRspecParser::SpecParsed
Class for storing data of parsed spec
Attributes
file[R]
Public Class Methods
find_spec_without_expect(folder)
click to toggle source
@return [Nothing] find specs without expect
# File lib/onlyoffice_rspec_parser/spec_parsed.rb, line 39 def self.find_spec_without_expect(folder) files = OnlyofficeFileHelper::FileHelper.list_file_in_directory(folder) files.each do |file| next unless file.end_with?('_spec.rb') parsed_spec = SpecParsed.new(file) parsed_spec.it_nodes.each do |current_it| next if current_it.include_expect? OnlyofficeLoggerHelper.log("There is no expect in #{current_it}") end end end
new(path)
click to toggle source
# File lib/onlyoffice_rspec_parser/spec_parsed.rb, line 11 def initialize(path) @file = path @parsed_data = Parser::CurrentRuby.parse(File.read(file)) end
Public Instance Methods
it_nodes()
click to toggle source
@return [Array<ItParsed>] list of it nodes in spec
# File lib/onlyoffice_rspec_parser/spec_parsed.rb, line 17 def it_nodes @it_nodes ||= search_node_for_it(@parsed_data) end
search_node_for_it(node)
click to toggle source
Search node for it @param [Parser::AST:Node] node for find @return [Array<Object>] nodes
# File lib/onlyoffice_rspec_parser/spec_parsed.rb, line 24 def search_node_for_it(node) nodes = [] node.children.each do |child| next unless child.is_a?(Parser::AST::Node) if child.to_s.start_with?("(send nil :it\n") nodes << ItParsed.new(node, file) else nodes += search_node_for_it(child) end end nodes end