Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
require 'rexml/document' require File.dirname(__FILE__) + '/../../../spec_helper' describe "REXML::Document#new" do it "initializes context to {} if context is not specified" do d = REXML::Document.new("<foo />") d.context.should == {} end it "has empty attributes if source is nil" do d = REXML::Document.new(nil) d.elements.empty?.should == true end it "clones the context from source if source is a Document" do s = REXML::Document.new("") d = REXML::Document.new(s) d.context.should == s.context end it "clones source's attributes source if a Document" do s = REXML::Document.new("<root />") s.attributes["some_attr"] = "some_val" d = REXML::Document.new(s) d.attributes.should == s.attributes end it "raises an error if source is not a Document, String or IO" do lambda {s = REXML::Document.new(3)}.should raise_error(RuntimeError) end it "expects source to be a valid XML document but it won't validate it" do lambda {s = REXML::Document.new("Invalid document")}.should_not raise_error(Exception) end end
From the Design Piracy series on my blog: