require 'spec_helper' describe AccountMembership do it { should belong_to(:account) } it { should belong_to(:user) } it { should validate_presence_of(:account_id) } it { should validate_presence_of(:user_id) } describe "given an existing account membership" do before { Factory(:account_membership) } it { should validate_uniqueness_of(:user_id).scoped_to(:account_id) } end end