Here's my test.
class AlertSettingTest < ActiveSupport::TestCase
context "For ALL Alert Settings" do
setup do
@alert = AlertSetting.create({ :alert_type_id=>'1',:name => 'xxx'})
end
subject { @alert }
should_belong_to :alert_type
should_validate_presence_of :name
end
end
Here's my model.
class AlertSetting < ActiveRecord::Base
belongs_to :alert_type
validates_presence_of :name, :message => "Alert name can't be blank."
validates_presence_of :alert_type_id, :message => "Please select valid Alert Type."
end
And I get Expected errors to include "can't be blank" when name is set to nil, got errors: name Alert name can't be blank. (nil)
I don't get it . Why? Thanks!