Dynamic fixture reading in a file

I have a text field in a database that I would like to populate with
some data. In my fixture yaml file I’m trying to read in the file as
an entry, but rails barfs on it.

Here’s what it looks like:

one:
id: 1
manifest: <%= File.read(‘MANIFEST’).to_yaml %>

The ‘MANIFEST’ file is a plist (a type of xml). The AR::read_fixtures
method barfs and complains that the yaml file requires a specific
kind of format.

Anyone know how to correctly read in a file inside a fixture to
populate a text field? Thanks

cr

On Nov 18, 2006, at 5:35 PM, [email protected] wrote:

The ‘MANIFEST’ file is a plist (a type of xml). The AR::read_fixtures
method barfs and complains that the yaml file requires a specific
kind of format.

I see the problem a little more clearly now. When I read in the file,
it has linefeeds and carriage returns in it which are preserved even
when converting to yaml. Apparently the yaml file requires all
multiline records to be indented the same way.

Luckily I do not need to preserve tabs, line feeds or carriage
returns, so I rewrote the line to strip those out. This has the
effect of keeping the file all on a single line in the yaml file, so
it doesn’t choke.

one:
id: 1
manifest: <%= File.read(‘MANIFEST’).gsub!(/[\t\n]/,’’) %>

Anyone know how to do this in the event that I do need to preserve
line feeds and carriage returns?

cr