hi
i am updating the data in unit testing

def test_for_update
    post=counties(:one)
    assert post.valid?, post.errors.full_messages
    assert post.update_attributes(:name=>"")
  end


name should not be empty but as you said i displayed

"assert post.valid?, post.errors.full_messages"

But i am not getting error message in assert but getting error message

please let me know whether i am right or wrong

please help



-- 
Karthik.k
Mobile - +91-9894991640


On Sat, Aug 1, 2009 at 2:46 PM, karthik k <[email protected]> wrote:

> hi Fred
>
> Thank you
>
> I will do the same
>
>
> --
> Karthik.k
> Mobile - +91-9894991640
>
>
> On Sat, Aug 1, 2009 at 2:13 PM, Frederick Cheung <
> [email protected]> wrote:
>
>>
>>
>>
>> On Aug 1, 9:13 am, karthik k <[email protected]> wrote:
>> > Hi Colin
>> >
>> > Thank you
>> > I saw that link but as a fresher not able to understand
>> > but if i have any doubt please guide me
>>
>> Like Colin said, your test is asserting that the record is saved
>> successfully. The most likely reason for this failing is if your model
>> has validations that are not being satisfied (and one way of working
>> out which one and why is to do as Colin suggested).
>>
>> Fred
>> >
>> > --
>> > Karthik.k
>> > Mobile - +91-9894991640
>> >
>> >
>> >
>> > On Sat, Aug 1, 2009 at 1:40 PM, Colin Law <[email protected]>
>> wrote:
>> >
>> > > 2009/8/1 karthik k <[email protected]>:
>> > > > Hi Colin
>> >
>> > > > Thank you very much
>> >
>> > > > can you please guide me for testing purpose because i am very new to
>> ruby
>> > > on
>> > > > rails
>> >
>> > > Did you try what I suggested?
>> >
>> > > If you have not already done so I would look at the RoR guides at
>> > >http://guides.rubyonrails.org/particularly Getting Started and
>> > > Testing Rails Applications.  Also the rest of them in fact.
>> >
>> > > Colin
>> >
>> > > > --
>> > > > Karthik.k
>> > > > Mobile - +91-9894991640
>> >
>> > > > On Sat, Aug 1, 2009 at 1:29 PM, Colin Law <[email protected]>
>> > > wrote:
>> >
>> > > >> 2009/8/1 karthik k <[email protected]>:
>> > > >> > def test_check_for_validity
>> > > >> >     post=County.new(:name=>"myname",:description=>"mydesc")
>> > > >> >     assert post.save
>> > > >> >   end
>> >
>> > > >> > above is the method and when i run unit test it is saying as
>> >
>> > > >> > 1) Failure:
>> > > >> > test_check_for_validity(CountyTest)
>> [/test/unit/county_test.rb:10]:
>> > > >> > <false> is not true.
>> >
>> > > >> > what does it say i cannot under stand
>> >
>> > > >> It is saying that the post.save failed (the assert is expecting
>> true,
>> > > >> so false makes the test fail).  Possibly your validations are
>> failing.
>> > > >>  If you put the line
>> >
>> > > >> assert post.valid?, post.errors.full_messages
>> >
>> > > >> before the save this will check the item for validity before
>> > > >> attempting to save it and show you any errors from validations (I
>> > > >> think).
>> >
>> > > >> Colin
>> >>
>>
>
>
> --
> Karthik.k
> Mobile - +91-9894991640
> http://kkarthikresume.blogspot.com/
>

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to