New Plugin: xls_fixtures

Posted by trevor Tue, 17 Oct 2006 17:54:46 GMT

Here’s a little something I whipped up that’s proved useful.

Yaml is a pretty good format for storing fixture data but it can be a real pain to set up a bunch of fixtures with repeating or incrementing data. There’s a much better tool out there for that – Excel.

One way you can ease the pain of generating reams of fixture data is to build it all up in Excel and export your spreadsheets as csv files and tell Rails to use csv fixtures. Unfortunately I couldn’t find a way to have a moniker (my name for the non-indented line in your yaml fixtures) in the csv files so that I could refer to fixtures by name in my tests.

So what I’ve done is to write a little plugin and rake task that converts xls files into yaml fixtures. See:

http://svn.protocool.com/public/plugins/trunk/xls_fixtures/

Note that it requires the ‘parseexcel’ gem (as in “gem install parseexcel”) and you need to arrange your rows and columns as per the README file in the plugin.

Posted in code | 2 comments