issue with serialized fields and testing

Hi all,

I have a work-around for my problem, but there's clearly something I don't quite understand going on here and I'd like to learn.

I have a model that has a serialized field. In the unit test for that model I'm checking the field contents. In my fixture I have

foo:   items: "<%=[3,8].to_yaml%>"

(thanks to Fred earlier for helping me get the fixtures loading without error - needed the quotes around the yaml)

and in the test I have

assert things(:foo).items == [3,8]

and... the test fails. The problem is that things(:foo).items ends up being an array that has a single element, the string '3 - 8'. For longer arrays the string becomes '3 - 8 - 1 - 2 - 3', for example.

I can get around this by explicitly stating the yaml string as

  manage_domains: "--- \n- 3\n- 8"

which leads to the assertion being true... but... it's inelegant, and I don't understand why the workaround is even necessary. It would be a lot easier to use and understand if I could get the first version working. From a couple of tests (printing to stdout) I think .to_yaml should be putting in the new-lines, but it seems not to be in this case.

Anyone care to enlighten me as to why the first version doesn't work, please?

  -Chris W