Archive for March, 2007

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: , ,

Posted by Andy on March 13th, 2007 No Comments