Created
August 13, 2013 16:11
-
-
Save abhishek0/6222796 to your computer and use it in GitHub Desktop.
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' | |
require 'faker' | |
describe Stampable do | |
it "throws error if stamp and contact is unset" do | |
expect { FactoryGirl.create(:user) }.to raise_error | |
end | |
it "can be saved if contact and stamp were set" do | |
user = FactoryGirl.build(:user) | |
user.stamp = FactoryGirl.build(:stamp) | |
user.stamp.contact = FactoryGirl.build(:contact) | |
user.save | |
expect(user.valid?).to be true | |
end | |
it "is unable to be saved if contact email already exists" do | |
FactoryGirl.create(:contact, email: '[email protected]') | |
user = FactoryGirl.build(:user) | |
user.stamp = FactoryGirl.build(:stamp) | |
user.stamp.contact = FactoryGirl.build(:contact, email: '[email protected]') | |
user.save | |
expect(user.valid?).to be false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment