Working on some validations earlier I thought it would be much cleaner and easier in some cases to be able to use either :if or :unless on a validation. It better fits my expectations as a rubyist. Also, it simplifies things when you are using a function in the if clause as you won't have to define both an affirmative and negative action.
I wanted it for open_id_authentication, so in my user model I can do something like:
def using_open_id?
!identity_url.blank?
end
validates_presence_of :identity_url, :if => using_open_id?
validates_presence_of :username, :unless => using_open_id?
validates_presence_of :password, :unless => using_open_id?
I changed the couple lines pertinent to if/unless within validations.rb as well as adding an explanation to the several places that it should come up in that document. As for the tests, I renamed the existing test_conditional_x tests with test_if_x tests. Then I made a copy of each of these name test_unless_x that uses unless and asserts the opposite result. Hopefully that should cover all the bases.