Sha256: 8b466c4725fd5101011e2aa2c9e11e6ceef32a0227c983c63676b2d55000b785
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
require 'spec/spec_helper' describe ROXML::XMLTextRef do before do @xml = ROXML::XML.parse_string %( <myxml> <node> <name>first</name> <name>second</name> <name>third</name> </node> </myxml>) end context "plain vanilla" do before do @ref = ROXML::XMLTextRef.new(OpenStruct.new(:name => 'name', :wrapper => 'node', :array? => false), RoxmlObject.new) end it "should return one instance" do @ref.value_in(@xml).should == "first" end it "should output one instance" end context "with :as => []" do before do @ref = ROXML::XMLTextRef.new(OpenStruct.new(:name => 'name', :wrapper => 'node', :array? => true), RoxmlObject.new) end it "should collect all instances" do @ref.value_in(@xml).should == ["first", "second", "third"] end it "should output all instances" do xml = ROXML::XML.new_node('myxml') @ref.update_xml(xml, ["first", "second", "third"]) xml.to_s.squeeze(' ').should == @xml.root.to_s.squeeze(' ') end end context "when the namespaces are different" do before do @xml = ROXML::XML.parse_string %( <myxml xmlns="http://example.com/three" xmlns:one="http://example.com/one" xmlns:two="http://example.com/two"> <node> <one:name>first</one:name> <two:name>second</two:name> <name>third</name> </node> </myxml>) end context "with :namespace => '*'" do before do @ref = ROXML::XMLTextRef.new(OpenStruct.new(:name => 'name', :wrapper => 'node', :array? => true, :namespace => '*'), RoxmlObject.new) end it "should collect all instances" do @ref.value_in(@xml).should == ["first", "second", "third"] end it "should output all instances with namespaces" do pending "Full namespace write support" xml = ROXML::XML.new_node('myxml') @ref.update_xml(xml, ["first", "second", "third"]) xml.should == @xml.root end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yob-roxml-3.1.6 | spec/xml/text_spec.rb |