Sha256: 9b1ea4d56ba9cbbe77ec9d91ec6ef01a4ce385a65842f19a75aa0d8b33415de1

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'
include Arbre

describe TextNode do

  it "should accept only a string in its build method" do
    node = arbre.append(TextNode, 'Test')
    expect(node.text).to eql('Test')
  end

  it "should be buildable using :text_node" do
    node = arbre.text_node('Test')
    expect(node).to be_a(TextNode)
    expect(node.text).to eql('Test')
  end

  it "should be able to be created from a string" do
    node = TextNode.from_string('Test')
    expect(node.text).to eql('Test')
  end

  it "should render its text only" do
    node = TextNode.new
    expect(node).to receive(:text).and_return('Test')
    expect(node.to_s).to eql('Test')
  end

  it "should always have an empty child collection" do
    node = TextNode.new
    expect(node.children).to be_empty
  end

  it "should be disallowed to add any children" do
    node = TextNode.new
    expect{ node.children << Element.new }.to raise_error(NotImplementedError)
    expect{ node.children.add Element.new }.to raise_error(NotImplementedError)
    expect{ node.children.concat [ Element.new ] }.to raise_error(NotImplementedError)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
arbre2-2.2.4 spec/arbre/unit/text_node_spec.rb
arbre2-2.2.3 spec/arbre/unit/text_node_spec.rb
arbre2-2.2.2 spec/arbre/unit/text_node_spec.rb
arbre2-2.2.1 spec/arbre/unit/text_node_spec.rb
arbre2-2.2.0 spec/arbre/unit/text_node_spec.rb
arbre2-2.1.0 spec/arbre/unit/text_node_spec.rb