diff options
Diffstat (limited to 'spec/ruby/library/rexml/attributes/shared')
-rw-r--r-- | spec/ruby/library/rexml/attributes/shared/add.rb | 17 | ||||
-rw-r--r-- | spec/ruby/library/rexml/attributes/shared/length.rb | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/spec/ruby/library/rexml/attributes/shared/add.rb b/spec/ruby/library/rexml/attributes/shared/add.rb new file mode 100644 index 0000000000..872f149f45 --- /dev/null +++ b/spec/ruby/library/rexml/attributes/shared/add.rb @@ -0,0 +1,17 @@ +describe :rexml_attribute_add, shared: true do + before :each do + @e = REXML::Element.new("root") + @attr = REXML::Attributes.new(@e) + @name = REXML::Attribute.new("name", "Joe") + end + + it "adds an attribute" do + @attr.send(@method, @name) + @attr["name"].should == "Joe" + end + + it "replaces an existing attribute" do + @attr.send(@method, REXML::Attribute.new("name", "Bruce")) + @attr["name"].should == "Bruce" + end +end diff --git a/spec/ruby/library/rexml/attributes/shared/length.rb b/spec/ruby/library/rexml/attributes/shared/length.rb new file mode 100644 index 0000000000..94681882a6 --- /dev/null +++ b/spec/ruby/library/rexml/attributes/shared/length.rb @@ -0,0 +1,13 @@ +require File.expand_path('../../../../../spec_helper', __FILE__) +require 'rexml/document' + +describe :rexml_attribute_length, shared: true do + it "returns the number of attributes" do + e = REXML::Element.new("root") + e.attributes.send(@method).should == 0 + + e.attributes << REXML::Attribute.new("name", "John") + e.attributes << REXML::Attribute.new("another_name", "Leo") + e.attributes.send(@method).should == 2 + end +end |