How to represent an Array in YAML Test fixtures


I have an Active Record column which I serialize into a Array of
Hashes, like below:

  serialize :sizes

which, when accessed produces and structure like:
  [{:quantity=>"1", :size=>1}, {:quantity=>"2", :size=>2},
{:quantity=>"2", :size=>3}]

this gets converted into YAML when stored in the DB.

I am having problems representing this in my YAML test fixtures.

I have tried the following:

  sizes: '--- \n- :quantity: "1"\n :size: 1\n- :quantity: "2"\n
:size: 2\n- :quantity: "2"\n :size: 3\n'


  sizes: <%= [{:quantity=>"1", :size=>1}, {:quantity=>"2", :size=>2},
{:quantity=>"2", :size=>3}].to_yaml %>

to no avail.

Does anybody how one might represent such an array in YAML?

   - 1
   - 2
   - 3

-- Marcus Brito

To those who come along, I found the following solution:

  sizes: [{!ruby/sym quantity: '5', !ruby/sym size: 1}, {!ruby/sym
quantity: '8', !ruby/sym size: 2}, {!ruby/sym quantity: '8', !ruby/sym
size: 3}]


More generally, you can find out the yaml format
for any data structure from the console:

  planb:/~ $ ./script/console
  Loading development environment.
  >> b = %w(eeny meeny miney mo)
  => ["eeny", "meeny", "miney", "mo"]
  >> require 'yaml'
  => false

Awesome! Spent way too much time reading the YAML specification to try
to make this work for me. Thanks for posting your solution and links.