From d99e78751ec6e3679343b4ac28f2ba9de427d505 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 28 Mar 2010 12:16:03 -0700 Subject: [PATCH] making sure psych defines to_yaml on object --- lib/psych/core_ext.rb | 6 ++++++ test/psych/helper.rb | 14 ++++++-------- test/psych/test_object_to_yaml.rb | 17 ----------------- 3 files changed, 12 insertions(+), 25 deletions(-) delete mode 100644 test/psych/test_object_to_yaml.rb diff --git a/lib/psych/core_ext.rb b/lib/psych/core_ext.rb index 7425d508..bd22219c 100644 --- a/lib/psych/core_ext.rb +++ b/lib/psych/core_ext.rb @@ -3,6 +3,12 @@ def self.yaml_tag url Psych.add_tag(url, self) end + # FIXME: rename this to "to_yaml" when syck is removed + + ### + # call-seq: to_yaml + # + # Convert an object to YAML def psych_to_yaml options = {} Psych.dump self, options end diff --git a/test/psych/helper.rb b/test/psych/helper.rb index 9cc75183..61049d6c 100644 --- a/test/psych/helper.rb +++ b/test/psych/helper.rb @@ -54,12 +54,10 @@ def mktime( year, mon, day, hour, min, sec, usec, zone = "Z" ) end end -o = Object.new -if o.respond_to?(:to_yaml) - if o.method(:to_yaml).source_location.first !~ /psych/ - Object.send :alias_method, :old_to_yaml, :to_yaml - Object.send :remove_method, :to_yaml - end -end - require 'psych' + +# FIXME: remove this when syck is removed +o = Object.new +a = o.method(:psych_to_yaml) +b = o.method(:to_yaml) +raise "psych should define to_yaml" unless a == b diff --git a/test/psych/test_object_to_yaml.rb b/test/psych/test_object_to_yaml.rb deleted file mode 100644 index 8025f30f..00000000 --- a/test/psych/test_object_to_yaml.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'test/psych/helper' - -module Psych - class TestObjectToYaml < TestCase - def test_object_has_to_yaml - o = Object.new - assert o.respond_to?(:to_yaml) - assert_equal o.method(:psych_to_yaml), o.method(:to_yaml) - - # Put the method back where we found it! - if o.respond_to?(:old_to_yaml) - Object.send :remove_method, :to_yaml - Object.send :alias_method, :to_yaml, :old_to_yaml - end - end - end -end