Some Shoulda Plugin Love

August 18th, 2008

I’ve been using Shoulda for some new projects and while it’s a learning experience I’m really pleased with the results. One thing I noticed right away is that I was testing for the presence and functionality of several Rails plugins I chose that are being used on many models.

I ended up writing custom Shoulda macros for three of the plugins: ActsAsTaggableOn, ActsAsCommentable and SaltySlugs. Below are the macros and an example of their usage in a test.

Shoulda Macros

Example Usage

$ ruby -Itest test/unit/album_test.rb 
Loaded suite test/unit/album_test
Started
…………………
Finished in 0.109251 seconds.

21 tests, 32 assertions, 0 failures, 0 errors

Leave a Reply