Can anyone please help me in writing rspec for the following method The write_entry_to_xml method write xml nodes.
The entry is an object which looks like
entry = Sitemap::Entry.new("http://www.example.com", 'monthly', 0.8, "2011-11-23 13:56:42 UTC")
def write_entry_to_xml(entry)
node = Nokogiri::XML::Node.new("url", @xml_document)
node["loc"] = entry.loc
node["lastmod"] = entry.lastmod.to_s
node["changefreq"] = entry.changefreq.to_s
node["priority"] = entry.priority.to_s
node.to_xml
end
Thanks
First off you should know what the expected output of your method should be. We can’t tell you what your code is supposed to be doing. Once you have that, your spec doesn’t have to be anything more than
Here I’ve assumed that this method is a class method on
SomeClass– change to match what you’ve done, you should also obviously replace “…” with the desired output