Created
February 7, 2013 03:48
-
-
Save johncblandii/4728284 to your computer and use it in GitHub Desktop.
Account Model Rspec Validations
This file contains 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
require 'spec_helper' | |
describe Account do | |
context "#validations" do | |
it{ FactoryGirl.build(:account).should be_valid } | |
it{ FactoryGirl.build(:account, name: "").should be_invalid } | |
it{ | |
FactoryGirl.build(:account, contact_email: "[email protected]").should be_valid | |
FactoryGirl.build(:account, contact_email: "[email protected]").should be_valid | |
FactoryGirl.build(:account, contact_email: "[email protected]").should be_valid | |
FactoryGirl.build(:account, contact_email: "[email protected]").should be_invalid | |
FactoryGirl.build(:account, contact_email: "@.com").should be_invalid | |
FactoryGirl.build(:account, contact_email: "jb@com").should be_invalid | |
FactoryGirl.build(:account, contact_email: "").should be_invalid | |
} | |
it{ | |
FactoryGirl.build(:account, contact_phone: "(555) 123-0555").should be_valid | |
FactoryGirl.build(:account, contact_phone: "(555)123-0555").should be_valid | |
FactoryGirl.build(:account, contact_phone: "555.123.0555").should be_valid | |
FactoryGirl.build(:account, contact_phone: "5551230555").should be_valid | |
FactoryGirl.build(:account, contact_phone: "(83)123-0555").should be_invalid | |
FactoryGirl.build(:account, contact_phone: "(555) 44-0555").should be_invalid | |
FactoryGirl.build(:account, contact_phone: "555.123.055").should be_invalid | |
} | |
it{ | |
FactoryGirl.build(:account, status: "active").should be_valid | |
FactoryGirl.build(:account, status: "ACTIVE").should be_valid | |
FactoryGirl.build(:account, status: "inactive").should be_valid | |
FactoryGirl.build(:account, status: "INACTIVE").should be_valid | |
FactoryGirl.build(:account, status: "somethingelse").should be_invalid | |
} | |
it{ | |
FactoryGirl.create(:account, subdomain: "validone").should be_valid | |
FactoryGirl.build(:account, subdomain: "validone").should be_invalid #must be unique | |
FactoryGirl.build(:account, subdomain: "3validone").should be_invalid | |
FactoryGirl.build(:account, subdomain: "validone32434").should be_invalid | |
FactoryGirl.build(:account, subdomain: "a").should be_invalid | |
FactoryGirl.build(:account, subdomain: "1").should be_invalid | |
FactoryGirl.build(:account, subdomain: "a123456789012345").should be_invalid | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment