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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 On Thu, Jul 7, 2011 at 1:31 PM, Yennie <joanne0558-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- thiagocifani http://thiagocifani.wordpress.com/ twitter.com/thiagocifani del.icio.us/thiagocifani <http://del.icio.us/thiagocifani> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
do you have other way to validate presence with message On Thu, Jul 7, 2011 at 12:39 PM, thiagocifani <cifani.thiago-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> 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 > > > On Thu, Jul 7, 2011 at 1:31 PM, Yennie <joanne0558-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > -- > thiagocifani > http://thiagocifani.wordpress.com/ > twitter.com/thiagocifani > del.icio.us/thiagocifani > <http://del.icio.us/thiagocifani> > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.