module ThoughtBot::Shoulda::ActiveRecord::Macros

def should_belong_to(*associations)


should_belong_to :parent

Ensure that the belongs_to relationship exists.
def should_belong_to(*associations)
  get_options!(associations)
  klass = model_class
  associations.each do |association|
    should "belong_to #{association}" do
      reflection = klass.reflect_on_association(association)
      assert reflection, "#{klass.name} does not have any relationship to #{association}"
      assert_equal :belongs_to, reflection.macro
      unless reflection.options[:polymorphic]
        associated_klass = (reflection.options[:class_name] || association.to_s.camelize).constantize
        fk = reflection.options[:foreign_key] || reflection.primary_key_name
        assert klass.column_names.include?(fk.to_s), "#{klass.name} does not have a #{fk} foreign key."
      end
    end
  end
end