Sha256: 78bbb9f4267ebeefb76a1951e8dad1cea50d2ed087118ce0b0213a14172d6e60
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 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 dump as object with value when attributes and contents are set" do element.set_attribute("foo", "bar") element.append_value("value") object = element.as_object object.foo.should == "bar" object.contents.should == "value" 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saxy-0.4.0 | spec/saxy/element_spec.rb |
saxy-0.3.0 | spec/saxy/element_spec.rb |
saxy-0.2.3 | spec/saxy/element_spec.rb |