Created
February 13, 2012 19:53
-
-
Save timuruski/1819679 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "validations" do | |
| context "birthday" do | |
| ["bad format","2100-01-01","1800-01-01","2000-13-01","2000-00-01","2000-01-32","2000-01-00"].each do |bday| | |
| it "errors with invalid date - #{bday}" do | |
| person = Person.create(:name => "not blank", :birthday => bday) | |
| person.errors.messages[:birthday].first.should == "is invalid" | |
| end | |
| end | |
| ["2099-12-31", nil].each do |bday| | |
| it "accepts with good birthday - #{bday}" do | |
| Person.count.should == 0 | |
| person = Person.create(:name => "name not blank", :birthday => "2099-12-31") #max year-max month-max day | |
| person.errors.messages.should == {} | |
| Person.count.should == 1 | |
| Person.first.name.should == "name not blank" | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment