diff --git a/lib/oga/xml/attribute.rb b/lib/oga/xml/attribute.rb
index 7f0c99f..01b3c40 100644
--- a/lib/oga/xml/attribute.rb
+++ b/lib/oga/xml/attribute.rb
@@ -67,12 +67,16 @@ module Oga
end
##
+ # Returns the value of the attribute.
+ #
# @return [String]
#
- def to_s
+ def text
return value.to_s
end
+ alias_method :to_s, :text
+
##
# @return [String]
#
diff --git a/spec/oga/xml/attribute_spec.rb b/spec/oga/xml/attribute_spec.rb
index 8d9bdb0..7a595d0 100644
--- a/spec/oga/xml/attribute_spec.rb
+++ b/spec/oga/xml/attribute_spec.rb
@@ -37,13 +37,13 @@ describe Oga::XML::Attribute do
end
end
- context '#to_s' do
+ context '#text' do
example 'return an empty String when there is no value' do
- described_class.new.to_s.should == ''
+ described_class.new.text.should == ''
end
example 'return the value if it is present' do
- described_class.new(:value => 'a').to_s.should == 'a'
+ described_class.new(:value => 'a').text.should == 'a'
end
end
diff --git a/spec/oga/xpath/evaluator/operators/eq_spec.rb b/spec/oga/xpath/evaluator/operators/eq_spec.rb
index b0411c3..81836fc 100644
--- a/spec/oga/xpath/evaluator/operators/eq_spec.rb
+++ b/spec/oga/xpath/evaluator/operators/eq_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Oga::XPath::Evaluator do
context 'equal operator' do
before do
- @document = parse('1010')
+ @document = parse('1010')
@evaluator = described_class.new(@document)
end
@@ -54,5 +54,9 @@ describe Oga::XPath::Evaluator do
example 'return true if a number and a node set wildcard are equal' do
@evaluator.evaluate('10 = root/*').should == true
end
+
+ example 'return true if an attribute and string are equal' do
+ @evaluator.evaluate('root/b/@class = "foo"').should == true
+ end
end
end