Sha256: a21a4b5f6b981f1372416ae1f0b8f0d336e39b69d5b648a59b9926e196f33d2f

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

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

describe TreeNodeVisitor do

  class Delegate
    def enter_node(node)
      @entered_node= true
    end

    def exit_node(node)
      @exit_node= true
    end

    def visit_leaf(leaf)
      @visited_leaf= true
    end
  end

  it "should use a delegate" do

    delegate = Delegate.new
    visitor = TreeNodeVisitor.new(delegate)

    visitor.enter_node(nil)
    expect(delegate.instance_eval{ @entered_node }).to be true

    visitor.exit_node(nil)
    expect(delegate.instance_eval{ @exit_node }).to be true

    visitor.visit_leaf(nil)
    expect(delegate.instance_eval{ @visited_leaf }).to be true
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tree.rb-0.3.13 spec/tree_rb/core/tree_node_visitor_delegate_spec.rb