Sha256: 5f9a9f503b34514cd0e708617d7e73b9bc2fa63b1c75213c3eac5d7104bd5603

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

require 'rexml/document'


describe "REXML::Element#add_element" do
  before :each do
    @root = REXML::Element.new("root")
  end

  it "adds a child without attributes" do
    name = REXML::Element.new("name")
    @root.add_element name
    @root.elements["name"].name.should == name.name
    @root.elements["name"].attributes.should == name.attributes
    @root.elements["name"].context.should == name.context
  end

  it "adds a child with attributes" do
    person = REXML::Element.new("person")
    @root.add_element(person, {"name" => "Madonna"})
    @root.elements["person"].name.should == person.name
    @root.elements["person"].attributes.should == person.attributes
    @root.elements["person"].context.should == person.context
  end

  it "adds a child with name" do
    @root.add_element "name"
    @root.elements["name"].name.should == "name"
    @root.elements["name"].attributes.should == {}
    @root.elements["name"].context.should == nil
  end

  it "returns the added child" do
    name = @root.add_element "name"
    @root.elements["name"].name.should == name.name
    @root.elements["name"].attributes.should == name.attributes
    @root.elements["name"].context.should == name.context
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubysl-rexml-2.0.4 spec/element/add_element_spec.rb
rubysl-rexml-2.0.3 spec/element/add_element_spec.rb
rubysl-rexml-1.0.0 spec/element/add_element_spec.rb
rubysl-rexml-2.0.2 spec/element/add_element_spec.rb
rubysl-rexml-2.0.1 spec/element/add_element_spec.rb