Sha256: d28820c01fa274f92f8d367a8ccd971569f8941b08baf1854c22dcf39e0d49ca
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
require 'spec_helper' describe Saxy::Element do let(:element) { Saxy::Element.new } it "should not append empty string as value" do element.append_value("") element.value.should be_nil end it "should append stripped value" do element.append_value(" foo ") element.append_value(" bar ") element.value.should == "foobar" end it "should dump as string when no attributes are set" do element.stub(:value).and_return("foo") element.as_object.should == "foo" end it "should dump as object when attributes are set" do element.stub(:attributes).and_return("foo" => 1, "bar" => 2) object = element.as_object object.foo.should == 1 object.bar.should == 2 end it "should add attributes under underscored names" do element.set_attribute("FooBar", "baz") element.as_object.foo_bar.should == "baz" end it "should create array if adding multiple attributtes with the same name" do element.set_attribute("foo", "bar") element.set_attribute("foo", "baz") element.as_object.foo.should == ["bar", "baz"] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
saxy-0.2.0 | spec/saxy/element_spec.rb |
saxy-0.1.2 | spec/saxy/element_spec.rb |