Permalink
Browse files

No need to use rescue block to require psych

  • Loading branch information...
1 parent 0bf51e9 commit 761b049b2e51a035eaf9c18f4d0200409848a28e Rafael Mendonça França committed Jan 4, 2012
@@ -1,8 +1,4 @@
-begin
- require 'psych'
-rescue LoadError
-end
-
+require 'psych'
require 'yaml'
require 'set'
require 'active_support/benchmarkable'
@@ -1,10 +1,5 @@
require 'erb'
-
-begin
- require 'psych'
-rescue LoadError
-end
-
+require 'psych'
require 'yaml'
require 'zlib'
require 'active_support/dependencies'
@@ -1,8 +1,4 @@
-begin
- require 'psych'
-rescue LoadError
-end
-
+require 'psych'
require 'erb'
require 'yaml'
@@ -1,4 +1,5 @@
-require "cases/helper"
+require 'psych'
+require 'cases/helper'
require 'models/topic'
class YamlSerializationTest < ActiveRecord::TestCase
@@ -36,22 +37,17 @@ def test_encode_with_coder
assert_equal({'attributes' => topic.attributes}, coder)
end
- begin
- require 'psych'
-
- def test_psych_roundtrip
- topic = Topic.first
- assert topic
- t = Psych.load Psych.dump topic
- assert_equal topic, t
- 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
+ def test_psych_roundtrip
+ topic = Topic.first
+ assert topic
+ t = Psych.load Psych.dump topic
+ assert_equal topic, t
+ 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
end
@@ -1,10 +1,5 @@
require 'bigdecimal'
-
-begin
- require 'psych'
-rescue LoadError
-end
-
+require 'psych'
require 'yaml'
class BigDecimal
@@ -1,8 +1,4 @@
-begin
- require 'psych'
-rescue LoadError
-end
-
+require 'psych'
require 'yaml'
YAML.add_builtin_type("omap") do |type, val|
@@ -1,3 +1,4 @@
+require 'psych'
require 'abstract_unit'
require 'active_support/json'
require 'active_support/core_ext/object/to_json'
@@ -291,21 +292,16 @@ def test_order_after_yaml_serialization_with_nested_arrays
assert_equal @ordered_hash.values, @deserialized_ordered_hash.values
end
- begin
- require 'psych'
+ def test_psych_serialize
+ @deserialized_ordered_hash = Psych.load(Psych.dump(@ordered_hash))
- def test_psych_serialize
- @deserialized_ordered_hash = Psych.load(Psych.dump(@ordered_hash))
-
- values = @deserialized_ordered_hash.map { |_, value| value }
- assert_equal @values, values
- end
+ values = @deserialized_ordered_hash.map { |_, value| value }
+ assert_equal @values, values
+ end
- def test_psych_serialize_tag
- yaml = Psych.dump(@ordered_hash)
- assert_match '!omap', yaml
- end
- rescue LoadError
+ def test_psych_serialize_tag
+ yaml = Psych.dump(@ordered_hash)
+ assert_match '!omap', yaml
end
def test_has_yaml_tag
@@ -1,9 +1,5 @@
require 'abstract_unit'
-begin
- require 'psych'
-rescue LoadError
-end
-
+require 'psych'
require 'active_support/core_ext/string/inflections'
require 'yaml'
@@ -1,10 +1,5 @@
require 'erb'
-
-begin
- require 'psych'
-rescue LoadError
-end
-
+require 'psych'
require 'yaml'
require 'optparse'
require 'rbconfig'

0 comments on commit 761b049

Please sign in to comment.