No need to use rescue block to require psych

This commit is contained in:
Rafael Mendonça França 2012-01-04 13:30:57 -03:00
parent 0bf51e9805
commit 761b049b2e
9 changed files with 29 additions and 68 deletions

View File

@ -1,8 +1,4 @@
begin require 'psych'
require 'psych'
rescue LoadError
end
require 'yaml' require 'yaml'
require 'set' require 'set'
require 'active_support/benchmarkable' require 'active_support/benchmarkable'

View File

@ -1,10 +1,5 @@
require 'erb' require 'erb'
require 'psych'
begin
require 'psych'
rescue LoadError
end
require 'yaml' require 'yaml'
require 'zlib' require 'zlib'
require 'active_support/dependencies' require 'active_support/dependencies'

View File

@ -1,8 +1,4 @@
begin require 'psych'
require 'psych'
rescue LoadError
end
require 'erb' require 'erb'
require 'yaml' require 'yaml'

View File

@ -1,4 +1,5 @@
require "cases/helper" require 'psych'
require 'cases/helper'
require 'models/topic' require 'models/topic'
class YamlSerializationTest < ActiveRecord::TestCase class YamlSerializationTest < ActiveRecord::TestCase
@ -36,22 +37,17 @@ class YamlSerializationTest < ActiveRecord::TestCase
assert_equal({'attributes' => topic.attributes}, coder) assert_equal({'attributes' => topic.attributes}, coder)
end end
begin def test_psych_roundtrip
require 'psych' topic = Topic.first
assert topic
t = Psych.load Psych.dump topic
assert_equal topic, t
end
def test_psych_roundtrip def test_psych_roundtrip_new_object
topic = Topic.first topic = Topic.new
assert topic assert topic
t = Psych.load Psych.dump topic t = Psych.load Psych.dump topic
assert_equal topic, t assert_equal topic.attributes, t.attributes
end
def test_psych_roundtrip_new_object
topic = Topic.new
assert topic
t = Psych.load Psych.dump topic
assert_equal topic.attributes, t.attributes
end
rescue LoadError
end end
end end

View File

@ -1,10 +1,5 @@
require 'bigdecimal' require 'bigdecimal'
require 'psych'
begin
require 'psych'
rescue LoadError
end
require 'yaml' require 'yaml'
class BigDecimal class BigDecimal

View File

@ -1,8 +1,4 @@
begin require 'psych'
require 'psych'
rescue LoadError
end
require 'yaml' require 'yaml'
YAML.add_builtin_type("omap") do |type, val| YAML.add_builtin_type("omap") do |type, val|

View File

@ -1,3 +1,4 @@
require 'psych'
require 'abstract_unit' require 'abstract_unit'
require 'active_support/json' require 'active_support/json'
require 'active_support/core_ext/object/to_json' require 'active_support/core_ext/object/to_json'
@ -291,21 +292,16 @@ class OrderedHashTest < Test::Unit::TestCase
assert_equal @ordered_hash.values, @deserialized_ordered_hash.values assert_equal @ordered_hash.values, @deserialized_ordered_hash.values
end end
begin def test_psych_serialize
require 'psych' @deserialized_ordered_hash = Psych.load(Psych.dump(@ordered_hash))
def test_psych_serialize values = @deserialized_ordered_hash.map { |_, value| value }
@deserialized_ordered_hash = Psych.load(Psych.dump(@ordered_hash)) assert_equal @values, values
end
values = @deserialized_ordered_hash.map { |_, value| value } def test_psych_serialize_tag
assert_equal @values, values yaml = Psych.dump(@ordered_hash)
end assert_match '!omap', yaml
def test_psych_serialize_tag
yaml = Psych.dump(@ordered_hash)
assert_match '!omap', yaml
end
rescue LoadError
end end
def test_has_yaml_tag def test_has_yaml_tag

View File

@ -1,9 +1,5 @@
require 'abstract_unit' require 'abstract_unit'
begin require 'psych'
require 'psych'
rescue LoadError
end
require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/string/inflections'
require 'yaml' require 'yaml'

View File

@ -1,10 +1,5 @@
require 'erb' require 'erb'
require 'psych'
begin
require 'psych'
rescue LoadError
end
require 'yaml' require 'yaml'
require 'optparse' require 'optparse'
require 'rbconfig' require 'rbconfig'