Based on the code below:
(1) How do you write a specification to verify that the class name home_team and away_team should be the class Team?
(2) Do you even have to write such a specification? Iβm not sure I see the value in this, but I wanted to get your thoughts.
class Event < ActiveRecord::Base
belongs_to :home_team, :class_name => 'Team', :foreign_key => :home_team_id
belongs_to :away_team, :class_name => 'Team', :foreign_key => :away_team_id
end
describe Event do
it { should belong_to(:home_team) }
it { should belong_to(:away_team) }
end
It would be nice if we had something like:
it { should belong_to(:home_team).with_class_name(:team) }
source
share