2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-01-11 18:14:26 -05:00
|
|
|
ruby_version_is ''...'2.8' do
|
|
|
|
require 'rexml/document'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-01-11 18:14:26 -05:00
|
|
|
describe "REXML::Text#value" do
|
|
|
|
it "returns the text value of this node" do
|
|
|
|
REXML::Text.new("test").value.should == "test"
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-01-11 18:14:26 -05:00
|
|
|
it "does not escape entities" do
|
|
|
|
REXML::Text.new("& \"").value.should == "& \""
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-01-11 18:14:26 -05:00
|
|
|
it "follows the respect_whitespace attribute" do
|
|
|
|
REXML::Text.new("test bar", false).value.should == "test bar"
|
|
|
|
REXML::Text.new("test bar", true).value.should == "test bar"
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-01-11 18:14:26 -05:00
|
|
|
it "ignores the raw attribute" do
|
|
|
|
REXML::Text.new("sean russell", false, nil, true).value.should == "sean russell"
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
2020-01-11 18:14:26 -05:00
|
|
|
describe "REXML::Text#value=" do
|
|
|
|
before :each do
|
|
|
|
@t = REXML::Text.new("new")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sets the text of the node" do
|
|
|
|
@t.value = "another text"
|
|
|
|
@t.to_s.should == "another text"
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-01-11 18:14:26 -05:00
|
|
|
it "escapes entities" do
|
|
|
|
@t.value = "<a>"
|
|
|
|
@t.to_s.should == "<a>"
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|