Permalink
Browse files

Check yaml by reparsing and check values as yaml string various great…

…ly between ruby versions/yaml engines
  • Loading branch information...
1 parent ee54348 commit 4cd4bfd6fbd8fc89ab4df208612e5024253feae7 @mnoack mnoack committed Jun 8, 2013
Showing with 30 additions and 3 deletions.
  1. +30 −3 test/test_geoloc.rb
View
@@ -63,9 +63,36 @@ def test_to_yaml
@loc.state = 'CA'
@loc.zip = '94105'
@loc.country_code = 'US'
- assert_equal(
- "--- !ruby/object:Geokit::GeoLoc\ncity: San Francisco\ncountry_code: US\nfull_address: \nlat: \nlng: \nprecision: unknown\nprovince: \nstate: CA\nstreet_address: \nstreet_name: \nstreet_number: \nsub_premise: \nsuccess: false\nzip: \'94105\'\n",
- @loc.to_yaml)
+
+ yaml = YAML::parse(@loc.to_yaml)
+ case yaml.class.to_s
+ when 'YAML::Syck::Map', 'Syck::Map'
+ tag = yaml.type_id
+ children = yaml.value.sort_by{|k, v| k.value}.flatten.map(&:value)
+ when 'Psych::Nodes::Mapping'
+ tag = yaml.tag
+ children = yaml.children.map(&:value)
+ when 'Psych::Nodes::Document'
+ tag = yaml.root.tag
+ children = yaml.root.children.map(&:value)
+ end
+ assert_match /.*object:Geokit::GeoLoc$/, tag
+ assert_equal [
+ 'city', 'San Francisco',
+ 'country_code', 'US',
+ 'full_address', '',
+ 'lat', '',
+ 'lng', '',
+ 'precision', 'unknown',
+ 'province', '',
+ 'state', 'CA',
+ 'street_address', '',
+ 'street_name', '',
+ 'street_number', '',
+ 'sub_premise', '',
+ 'success', 'false',
+ 'zip', '94105'
+ ], children
end
def test_neighborhood

0 comments on commit 4cd4bfd

Please sign in to comment.