Sha256: b04ee6a01a373fc7fbe5c5cf1ceb4c9e2809cd0f7ee93715d12a3e385430652b

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

require 'rexml/document'

describe "REXML::Element#text" do
  before :each do
    @e = REXML::Element.new "name"
    @e.text = "John"
  end

  it "returns the text node of element" do
    @e.text.should == "John"
  end

  it "returns the text node value" do
    t = REXML::Text.new "Joe"
    @e.text = t
    @e.text.should == "Joe"
    @e.text.should_not == t
  end

  it "returns nil if no text is attached" do
    elem = REXML::Element.new "name"
    elem.text.should == nil
  end
end

describe "REXML::Element#text=" do
  before :each do
    @e = REXML::Element.new "name"
    @e.text = "John"
  end

  it "sets the text node" do
    @e.to_s.should == "<name>John</name>"
  end

  it "replaces existing text" do
    @e.text = "Joe"
    @e.to_s.should == "<name>Joe</name>"
  end

  it "receives nil as an argument" do
    @e.text = nil
    @e.to_s.should == "<name/>"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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