error of should validate_presence_of (shoulda)

Hi all,

I am a new user of shoulda unit test and using the shoulda to test the
model
and I get the error as below

the error is
1) Failure:
test: validation od reason should require phrase_id to be set.
(ReasonTest) [/usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/
shoulda/context.rb:324]:
Expected errors to include "can't be blank" when phrase_id is set to
nil, got errors: ["prescription_id ERROR_MISSING_PRESCRIPTION (nil)",
"phrase_id ERROR_MISSING_PHRASE (nil)"].
Expected block to return true value.

model
class Reason < ActiveRecord::Base

  validates_presence_of :prescription_id, :message =>
"ERROR_MISSING_PRESCRIPTION"
  validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE"

  belongs_to :prescription
  belongs_to :phrase
end

context 'validation od reason' do

    should validate_presence_of :prescription_id
    should validate_presence_of :phrase_id
    should belong_to :prescription
    should belong_to :phrase
  end

plz help me ..

thanks

Yennie

Hey dude,

I think the most simplist thing to do here could be use the rails helper!

validates_associated :pages, :library

shoulda should have some helper to verify the existence of a relationship

here is my tow cents

hugs

do you have other way to validate presence with message