Given the code below:
(1) How would you write a spec to test that the class name of home_team and away_team should be a Team class?
(2) Should you even bother to write such a spec? I'm not sure I see the value in doing so, but 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
Would be nice if shoulda had something like:
it { should belong_to(:home_team).with_class_name(:team) }