class Shoulda::Matchers::ActiveRecord::AssociationMatchers::ModelReflection

def association_foreign_key

def association_foreign_key
  if has_and_belongs_to_many_reflection
    join_model = has_and_belongs_to_many_reflection.options[:class]
    join_model.right_reflection.foreign_key
  else
    reflection.association_foreign_key
  end
end