Sha256: 870b0480b4f35c5f7a3ddf6218d540b6c6c70b92085e08418ed1cafa73ed407a

Contents?: true

Size: 994 Bytes

Versions: 8

Compression:

Stored size: 994 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

8 entries across 8 versions & 1 rubygems

Version Path
tree.rb-0.3.10 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
tree.rb-0.3.9 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
tree.rb-0.3.8 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
tree.rb-0.3.7 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
tree.rb-0.3.6 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
tree.rb-0.3.5 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
tree.rb-0.3.4 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb
tree.rb-0.3.3 spec/tree_rb/tree_dsl_with_derived_class1_spec.rb