Permalink
Browse files

Fix undefined method `syck_to_yaml' for class `Object' error.

  • Loading branch information...
1 parent 3b652d8 commit f0f7ed5a998cfad689bfa4672d33a737148002f5 @KL-7 KL-7 committed Nov 13, 2012
Showing with 21 additions and 16 deletions.
  1. +21 −16 spec/utils/yaml/yaml_spec.rb
@@ -7,30 +7,35 @@
# https://github.com/afunai/ya2yaml
# Copyright (c) 2006 Akira FUNAI <funai.akira@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
+#
+# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
require 'spec_helper'
require 'yaml'
# Psych doesn't handle Unicode characters properly, have to use Syck instead.
-YAML::ENGINE.yamler = 'syck' if YAML.const_defined?(:ENGINE)
+if YAML.const_defined?(:ENGINE)
+ # Fix undefined method `syck_to_yaml' for class `Object' error on MRI 1.9.3.
+ # Target only MRI >= 1.9, because on other Rubies, e.g., JRuby, requiring 'syck' results in a LoadError.
+ require 'syck' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby'
+ YAML::ENGINE.yamler = 'syck'
+end
# There's an incompatibility in how ruby handles struct dumps
# between versions that's beyond our scope.

0 comments on commit f0f7ed5

Please sign in to comment.