views:

19

answers:

1

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!

A: 

Well well. If I comment out the :message part in my validations inside my model the test script RUNS ! Now, if somebody could explain why that is the case , that would be great. Any chance its a shoulda bug?

Shreyas Satish