From 4513aeea6f6a182a4bb2eff5dfd3f998a23da5ff Mon Sep 17 00:00:00 2001 From: Chris Gaffney Date: Fri, 11 Feb 2011 14:12:30 -0500 Subject: [PATCH] Add failing test for deserializing poorly formatted, non-delayed job based yaml loading. --- spec/yaml_ext_spec.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/spec/yaml_ext_spec.rb b/spec/yaml_ext_spec.rb index 5aeed79dc..40fd08d22 100644 --- a/spec/yaml_ext_spec.rb +++ b/spec/yaml_ext_spec.rb @@ -3,14 +3,29 @@ describe YAML do it "should autoload classes that are unknown at runtime" do lambda { - YAML.load("--- !ruby/object:Autoloaded::Clazz {}") + obj = YAML.load("--- !ruby/object:Autoloaded::Clazz {}") + obj.class.to_s.should == 'Autoloaded::Clazz' }.should_not raise_error end it "should autoload structs that are unknown at runtime" do lambda { - YAML.load("--- !ruby/struct:Autoloaded::Struct {}") + obj = YAML.load("--- !ruby/struct:Autoloaded::Struct {}") + obj.class.to_s.should == 'Autoloaded::Struct' }.should_not raise_error end + + # As we're overriding some of Yaml's internals it is best that our changes + # don't impact other places where Yaml is used. Or at least don't make it + # look like the exception is caused by DJ + it "should not raise exception on poorly formatted yaml" do + lambda do + YAML.load(<<-EOYAML +default: + <<: *login +EOYAML + ) + end.should_not raise_error + end -end \ No newline at end of file +end