任何人都可以幫我寫下rspec爲以下方法write_entry_to_xml方法寫入xml節點。 入口是一個對象,它看起來像Rspec爲以下方法
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
感謝
編寫一個規範,使用您的方法和一些示例輸入,並檢查輸出是否如預期。你不明白什麼? – 2012-01-13 09:24:11
@Frederick Cheung你能告訴我一個例子,我怎樣才能爲我的方法創建一些預定義的輸入數據,並運行我的方法與該數據,以確認輸出是我期望的...謝謝 – gikian 2012-01-13 09:26:20
獲取此書:[ RSpec書](http://pragprog.com/book/achbd/the-rspec-book),你將沒有問題:-) – 2012-01-13 10:30:58