Sha256: a4be22e1b0a404f8c3cfd27e40b0be38c610a5544273c6ad6c9843c25b8d040b

Contents?: true

Size: 880 Bytes

Versions: 4

Compression:

Stored size: 880 Bytes

Contents

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

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

  class DTreeNode < TreeNode
    def content
      "dt: #{super}"
    end
  end

  class DLeafNode < LeafNode
    def content
      "dl: #{super}"
    end
  end

  it "dsl with non-arg constructor" do
    tree = TreeNode.create(DTreeNode, DLeafNode) do
      node "root" do
        leaf "l1"
        leaf "l2"
        node "sub" do
          leaf "l3"
        end
      end
    end

    puts tree.to_str
    out =<<EOS
dt: root
|-- dl: l1
|-- dl: l2
`-- dt: sub
    `-- dl: l3
EOS
    tree.to_str.should == out

    tree = DTreeNode.create(DLeafNode) do
      node "root" do
        leaf "l1"
        leaf "l2"
        node "sub" do
          leaf "l3"
        end
      end
    end
    tree.to_str.should == out
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tree.rb-0.3.6 spec/tree_rb/tree_dsl_with_derived_class_spec.rb
tree.rb-0.3.5 spec/tree_rb/tree_dsl_with_derived_class_spec.rb
tree.rb-0.3.4 spec/tree_rb/tree_dsl_with_derived_class_spec.rb
tree.rb-0.3.3 spec/tree_rb/tree_dsl_with_derived_class_spec.rb