Sha256: 9d3e941fb4d8477f5e8e8b2ae8cb6d1d7e2a7a87135b5d91e8b0f8ff0270e569

Contents?: true

Size: 882 Bytes

Versions: 4

Compression:

Stored size: 882 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.10 spec/tree_rb/tree_dsl_with_derived_class_spec.rb
tree.rb-0.3.9 spec/tree_rb/tree_dsl_with_derived_class_spec.rb
tree.rb-0.3.8 spec/tree_rb/tree_dsl_with_derived_class_spec.rb
tree.rb-0.3.7 spec/tree_rb/tree_dsl_with_derived_class_spec.rb