Added Attribute#parent

This commit is contained in:
Yorick Peterse 2015-08-28 16:22:42 +02:00
parent d0177633f8
commit 07658dadb1
2 changed files with 11 additions and 0 deletions

View File

@ -17,6 +17,8 @@ module Oga
# @return [Oga::XML::Element] # @return [Oga::XML::Element]
attr_accessor :element attr_accessor :element
alias_method :parent, :element
## ##
# The default namespace available to all attributes. This namespace can # The default namespace available to all attributes. This namespace can
# not be modified. # not be modified.

View File

@ -11,6 +11,15 @@ describe Oga::XML::Attribute do
end end
end end
describe '#parent' do
it 'returns the parent Element' do
element = Oga::XML::Element.new(:name => 'foo')
attr = described_class.new(:element => element)
attr.parent.should == element
end
end
describe '#namespace' do describe '#namespace' do
before do before do
@namespace = Oga::XML::Namespace.new(:name => 'b') @namespace = Oga::XML::Namespace.new(:name => 'b')