[Rails] 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
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home