Add to_s as an alias to the to_xml method
This commit is contained in:
parent
5bdd0207a0
commit
2142243227
|
@ -7,6 +7,8 @@ module Oga
|
|||
def to_xml
|
||||
Generator.new(self).to_xml
|
||||
end
|
||||
|
||||
alias_method :to_s, :to_xml
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Oga::XML::ToXML do
|
||||
describe '#to_s' do
|
||||
it 'is an alias of to_xml' do
|
||||
node = Oga::XML::Element.new(name: 'foo')
|
||||
|
||||
expect(node.method(:to_s)).to eq(node.method(:to_xml))
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue