Skip to content

Instantly share code, notes, and snippets.

@abhishek0
Created August 13, 2013 16:11
Show Gist options
  • Save abhishek0/6222796 to your computer and use it in GitHub Desktop.
Save abhishek0/6222796 to your computer and use it in GitHub Desktop.
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: 'example@example.com')
user = FactoryGirl.build(:user)
user.stamp = FactoryGirl.build(:stamp)
user.stamp.contact = FactoryGirl.build(:contact, email: 'example@example.com')
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