Prev | Current Page 317 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

If order
will matter in your testing, you should use the Ordered Mapping Language-Independent (omap)
Type for YAML. You can learn more about the omap type and the entire YAML syntax at http://
www.yaml.org.
CSV
CSV stands for ???comma separated value??? and is one of the oldest and historically most commonly
used data exchange formats. So it??™s probably no surprise that you can use that format
with Active Record fixtures as well.
Like YAML fixtures, CSV fixtures are all stored in one file per model (or rather, one file per
database table). Each file should be located in the directory set by the TestCase.fixture_path
method (or in the create_fixtures method, as we described previously). Each file should also
have the .csv extension. Within the file, the first line should be a comma separated list of field
names, and each additional line should be the actual data, with one record per line.
CHAPTER 6 ?–  ACTIVE RECORD TESTING AND DEBUGGING 142
Since the comma is a special character in the CSV format, you must wrap any data that
contains a comma inside of double quotes.


Pages:
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329