From: Shaun McDonald Date: Tue, 9 Jun 2009 14:37:47 +0000 (+0000) Subject: More Node.from_xml unit tests X-Git-Tag: live~7615 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3170600b9c6a1a42a1b2385fff08eca1c5f07b26 More Node.from_xml unit tests --- diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index d65fe5568..21a62cc5f 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb @@ -221,15 +221,38 @@ class NodeTest < ActiveSupport::TestCase assert_match /changeset id missing/, message_update.message end + def test_from_xml_no_version + no_version = "" + assert_nothing_raised(OSM::APIBadXMLError) { + Node.from_xml(no_version, true) + } + message_update = assert_raise(OSM::APIBadXMLError) { + Node.from_xml(no_version, false) + } + assert_match /Version is required when updating/, message_update.message + end + def test_from_xml_double_lat nocs = "" message_create = assert_raise(OSM::APIBadXMLError) { Node.from_xml(nocs, true) - } + } assert_match /Fatal error: Attribute lat redefined at/, message_create.message message_update = assert_raise(OSM::APIBadXMLError) { Node.from_xml(nocs, false) } assert_match /Fatal error: Attribute lat redefined at/, message_update.message end + + def test_from_xml_no_text + no_text = "" + message_create = assert_raise(OSM::APIBadXMLError) { + Node.from_xml(no_text, true) + } + assert_match /Must specify a string with one or more characters/, message_create.message + message_update = assert_raise(OSM::APIBadXMLError) { + Node.from_xml(no_text, false) + } + assert_match /Must specify a string with one or more characters/, message_create.message + end end