Skip to content

Commit

Permalink
Test alternate psych struct fix
Browse files Browse the repository at this point in the history
  • Loading branch information
albus522 committed Jun 30, 2014
1 parent 42b1489 commit 0c0a38a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/delayed/psych_ext.rb
Expand Up @@ -136,6 +136,8 @@ def visit_Psych_Nodes_Mapping_with_class(object) # rubocop:disable CyclomaticCom
alias_method_chain :visit_Psych_Nodes_Mapping, :class

def resolve_class_with_constantize(klass_name)
return resolve_class_without_constantize(klass_name) if klass_name.blank?

klass_name.constantize
rescue
resolve_class_without_constantize(klass_name)
Expand Down
7 changes: 7 additions & 0 deletions spec/yaml_ext_spec.rb
Expand Up @@ -22,6 +22,13 @@
end.not_to raise_error
end

it 'autoloads the class of an anonymous struct' do
yaml = "--- !ruby/struct\nn: 1\n"
object = YAML.load(yaml)
expect(object).to be_kind_of(Struct)
expect(object.n).to eq(1)
end

it 'autoloads the class for the instance' do
expect do
yaml = "--- !ruby/object:Autoloaded::InstanceClazz {}\n"
Expand Down

0 comments on commit 0c0a38a

Please sign in to comment.