Sha256: 55f1291d382170ca6489498ff73c6a81f7ebb27479b125b0a2eed01eb8b5687a

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

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

describe "Tree Node Dsl Derived Class with n-arg constructor" do

  class ArgsTreeNode < TreeNode
    attr_reader :description

    def initialize(name, description, parent)
      content = "a: #{description}"
      super(content, parent)
      @description = description
    end

  end

  class ArgsLeafNode < LeafNode
    attr_reader :description

    def initialize(name, description, parent)
      content = "a: #{description}"
      super(content, parent)
      @description = description
    end

  end

  it "test_derivated_args" do
    tree = TreeNode.create(ArgsTreeNode, ArgsLeafNode) do
      node "root", "droot" do
        leaf "l1", "dl1"
        leaf "l2", "dl2"
        node "sub", "dsub" do
          leaf "l3", "dl3"
        end
      end
    end

    # puts tree.to_str
    out =<<EOS
a: droot
|-- a: dl1
|-- a: dl2
`-- a: dsub
    `-- a: dl3
EOS
    tree.to_str.should == out
  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_with_derived_class1_spec.rb
tree.rb-0.3.11 spec/tree_rb/core/tree_dsl_with_derived_class1_spec.rb