Sha256: ad06e155608ecc341177557e41453a3a0b240eb0a0c89b64f90494b6634556d8

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

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

describe "TreeNodeDsl" do

  it "should build tree with dsl" do
    tree = TreeNode.create do
      node "root" do
        leaf "l1"
        leaf "l2"
        node "sub" do
          leaf "l3"
        end
        node "wo leaves"
      end
    end

    # puts tree.to_str
    out =<<EOS
root
|-- l1
|-- l2
|-- sub
|   `-- l3
`-- wo leaves
EOS
    tree.to_str.should == out
  end

  it "test_dsl_block_with_arg" do
    tree = TreeNode.create do
      node "root" do |node|
        node.prefix_path=("pre/")
        leaf "l1"
        leaf "l2"
        node "sub" do
          leaf "l3" do |leaf|
          end
        end
        node "woleaves"
      end
    end

    # puts tree.to_str
    out =<<EOS
root
|-- l1
|-- l2
|-- sub
|   `-- l3
`-- woleaves
EOS
    tree.to_str.should ==  out
    tree.find("l3").path_with_prefix.should == "pre/root/sub/l3"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tree.rb-0.3.12 spec/tree_rb/core/tree_dsl_spec.rb
tree.rb-0.3.11 spec/tree_rb/core/tree_dsl_spec.rb