Created
April 17, 2011 17:48
-
-
Save benlangfeld/924279 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
Factory.sequence :email do |n| | |
"user#{n}@example.com" | |
end | |
Factory.define :user do |u| | |
u.email { Factory.next :email } | |
u.password 'eeoo1100' | |
u.password_confirmation { |u| u.password } | |
u.phone_number '4158489676' | |
u.available true | |
end |
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 User do | |
subject { Factory.create :user, :email => "[email protected]" } | |
describe "phone number" do | |
it "is valid when well formed" do | |
subject.phone_number = "4158489676" | |
should be_valid | |
end | |
describe "is invalid when" do | |
it "not present" do | |
subject.phone_number = "" | |
should be_invalid | |
end | |
it "too short" do | |
subject.phone_number = "48451" | |
should be_invalid | |
end | |
it "too long" do | |
subject.phone_number = "486789745415648435" | |
should be_invalid | |
end | |
it "non-numeric" do | |
subject.phone_number = "fewf1548fwf" | |
should be_invalid | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment