From 07658dadb1559a83ea385ace4d8467fa11914771 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 28 Aug 2015 16:22:42 +0200 Subject: [PATCH] Added Attribute#parent --- lib/oga/xml/attribute.rb | 2 ++ spec/oga/xml/attribute_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/oga/xml/attribute.rb b/lib/oga/xml/attribute.rb index 4abbb43..823219f 100644 --- a/lib/oga/xml/attribute.rb +++ b/lib/oga/xml/attribute.rb @@ -17,6 +17,8 @@ module Oga # @return [Oga::XML::Element] attr_accessor :element + alias_method :parent, :element + ## # The default namespace available to all attributes. This namespace can # not be modified. diff --git a/spec/oga/xml/attribute_spec.rb b/spec/oga/xml/attribute_spec.rb index 64c6e61..809b1bc 100644 --- a/spec/oga/xml/attribute_spec.rb +++ b/spec/oga/xml/attribute_spec.rb @@ -11,6 +11,15 @@ describe Oga::XML::Attribute do 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 before do @namespace = Oga::XML::Namespace.new(:name => 'b')