Sha256: f1e5e79c887f54a5fe9d8debaff60c8724d66c39a4e4147b249cf2d507c2c549

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

# -*- coding: utf-8 -*-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")

describe "Tree Node Visitors" do

  before do
    ta = TreeNode.new( "a", nil )
    LeafNode.new("1", ta )
    LeafNode.new("2", ta )
    
    tb = TreeNode.new( "b", ta )
    LeafNode.new( "3", tb ) 
    
    @tree = ta
  end

  it BlockTreeNodeVisitor do
    accumulator = []
    visitor = BlockTreeNodeVisitor.new { |node| accumulator << node.content}
    @tree.accept( visitor )
    expect(accumulator.length).to be == 5
    expect(accumulator).to be == %w{ a 1 2 b 3 }
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tree.rb-0.3.13 spec/tree_rb/visitors/block_tree_node_visitor_spec.rb