Add to_s as an alias to the to_xml method

This commit is contained in:
Roy Zwambag 2020-07-27 00:14:36 +00:00 committed by Yorick Peterse
parent 5bdd0207a0
commit 2142243227
2 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,8 @@ module Oga
def to_xml
Generator.new(self).to_xml
end
alias_method :to_s, :to_xml
end
end
end

View File

@ -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