我的 Line 模型中有这个
validates :home_team, :uniqueness => { :scope => [:visiting_team, :event_datetime],
:message => "** DOUBLE EVENT **" }
我的规格中有这个
describe Line do
it { should validate_uniqueness_of(:home_team).scoped_to(:visiting_team, :event_datetime) }
我得到这个错误...
失败:
1) Line
Failure/Error:
it { should validate_uniqueness_of(:home_team).scoped_to(:visiting_team, :event_datetime) }
Did not expect errors to include "has already been taken" when home_team is set to "arbitrary_string", got error:
# ./spec/models/line_spec.rb:7:in `block (2 levels) in <top (required)>'
任何想法为什么这会失败?