Hi guys,
I'm seeing some strange behavior with YAML serialization/deserialization
and would like someone to explain what's going on with this, if
possible.
I attached two files that you can run with:
spec battle_spec.rb (this one fails)
spec battle2_spec.rb (this one doesn't fail)
The difference between the two, is just a character in the name of an
instance variable.
The source code is very simple. It has three classes to represent a
nested structure:
A Battlefield might contain many teams, a Team might contain many
Warriors. In my sample it's just one of each, to keep it simple.
The problem is that, the Team @members are nullified in some cases.
battle_spec.rb shows a case where Team#members is nil.
battle2_spec.rb shows a case where Team#members is not nil (just
changing a character in a instance variable name, the one that makes the
Battlefield accessible for a Team [a var to point to its parent]).
I'm kinda new to this testing stuff, maybe I'm doing something wrong, if
that's the case, I'll be glad to hear any advice or pointers.
If you need more info, I'll be glad to provide it.
Best regards,
Víctor Adrián.
battle_spec.rb (765 Bytes)
battle2_spec.rb (762 Bytes)