Mike GehardMike Gehard
Testing Rails3 Generators using Cucumber and Aruba
edit Posted by Mike Gehard on Wednesday September 15, 2010 at 06:34AM

In an effort to continue my contributions to the open source Ruby/Rails ecosystem, I decided to help the factory_girl_rails team move the Rails3 generators from the rails3-generators project into the factory_girl_rails project.

Like all good Ruby/Rails developers, they asked to make sure that I had tests written around the generators. I thought for a bit on how I was going to do this and then I wandered across the Cucumber feature files in the rspec-rails repo and found my answer.

Rspec-rails (and RSpec2 as well) uses a gem called Aruba to easily write Cucumber features around things that happen from the command line.

If you'd like to check out the result of using Cucumber and Aruba to test Rails3 generators, head over to my fork of the factory_girl_rails gem and check out the features/generators.feature file.

Hopefully the changes will be merged into the official factory_girl_rails repo soon and the generators will live closer to home.

Comments

  1. Jack Dempsey Jack Dempsey on September 15, 2010 at 09:41AM

    Nice post Mike, I haven't seen many people talking about aruba just yet, and I think it's an excellent lib that makes testing command line and file system features much easier.

    I've begun using it on a new idea of mine, code over at github of course: http://github.com/jackdempsey/writeme

    Hopefully this can give some further examples on ways to do things. I know I had to bug Aslak on the cucumber list to get a few things straight in my mind.

  2. Andrea Franz Andrea Franz on September 16, 2010 at 03:53AM

    Awesome, I love testing generators with cucumber! I have to port some of my generators to rails 3, I'll check your repo to study more about the rails 3 generators :)

  3. Mike Gehard Mike Gehard on September 16, 2010 at 06:10AM

    Andrea, thanks for the comment and the inspiration. I got the idea of testing the generators with Cucumber from your blog.

  4. Andrea Franz Andrea Franz on September 16, 2010 at 01:45PM

    Cool! and now I'll take inspiration from your work on rails 3 ;)