Rails: ActiveSpec

I’ve discovered Luke Redpaths ActiveSpec gem, and it looks great, particularly for validating objects conditionally based on state. Example:

class User
  must_satisfy :valid_user_specification
  must_satisfy :activated_user_specification,
    :if => :activated?
end

That’s a lot neater than lots of conditionals scattered through validation statements. And funnily enough, this precise scenario (users validating differently depending on activation) is something I was working on two weeks ago.

Technorati Tags: , ,

Tags: , ,

This entry was posted on Tuesday, March 13th, 2007 at 11:43 am and is filed under Coding. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.

 

Comments are closed.