My Question
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
please help
your answer
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
My question
> 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
On Sat, Aug 1, 2009 at 4:26 PM, Colin Law <[email protected]> wrote:
>
> 2009/8/1 karthik k <[email protected]>:
> > hi Colin
> >
> > 1) Failure:
> > test_for_update(CountyTest) [test/unit/county_test.rb:19]:
> > Name has already been taken.
> > <false> is not true.
> >
> >
>
your answer
>
> Could you reply with your comments inserted into the existing email
> please rather than at the top, it makes it much easier to follow the
> thread, so your comment above should have been after my bit asking for
> the error.
>
> Have you got a validates_uniqueness_of :name? I think the error means
> there are two with the same name. If you can't see the problem post
> your counties.yml.
>
> Earlier it was suggested that you look at the rails guides Getting
> Started and Testing. Have you done that and do you understand all
> that is in them? (Or at least understand most of it)
>
> Colin
>
>
Yes
i have validates_uniqueness_of :name
what i need to do
please help
karthik.k
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---