Skip to content

Instantly share code, notes, and snippets.

@marciok
Created January 31, 2013 13:26
Show Gist options
  • Save marciok/4682848 to your computer and use it in GitHub Desktop.
Save marciok/4682848 to your computer and use it in GitHub Desktop.
# app/model/user.rb
has_and_belongs_to_many :friends, class_name: 'User', inverse_of: :friends
# spec/model/user_spec.rb
it { should have_and_belong_to_many(:friends).of_type('User').as_inverse_of(:friends) }
# Error message
#1) User Associations
# Failure/Error: it { should have_and_belong_to_many(:friends).of_type('User').as_inverse_of(:friends) }
# Expected User to reference and referenced in many "friends" of type "User" which is an inverse of "friends", got User #references and referenced in many friends of type User
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment