Sha256: e23818af45811dd5445bcafaac957c6b2e776f1f7f4010b30bfab3d27a45659a
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require 'spec_helper' describe TodoNext::Tree, 'visiting the tree depth-first' do class SimpleVisitor < TodoNext::Tree::Visitor::Base def process_terminal_node(curr_node, level, parent) curr_node.text end def process_non_terminal_node(curr_node, level, parent) result = curr_node.children.collect { |node| visit(node, 1+level, self) }.join(', ') "#{curr_node.text}=[#{result}]" end end it 'visits the tree depth-first' do expected = ['HEADER 1=[HEADER 2=[HEADER 3=[spec a, spec b]]]' , 'HEADER 4=[spec c]', 'HEADER 5', 'HEADER 6' ] source = 'HEADER 1' + "\n" + ' HEADER 2' + "\n" + ' HEADER 3' + "\n" + ' spec a' + "\n" + ' spec b' + "\n" + 'HEADER 4' + "\n" + ' spec c' + "\n" + 'HEADER 5' + "\n" + 'HEADER 6' TodoNext::Parser. parse(source). visit(SimpleVisitor.new). should == expected end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
todo_next-0.0.2 | spec/02_visit_the_tree_spec.rb |