Hi Colin

the name field is made as

validates_uniqueness_of :name

so please let me know what i did is right or wrong
though the name is different it is providing the error message

Is this the right way to check uniqueness

I got the information from from

http://railstips.org/2009/1/8/test-or-die-validates-uniqueness-of

Please help


-- 
Karthik.k
Mobile - +91-9894991640


On Sat, Aug 1, 2009 at 6:43 PM, Colin Law <[email protected]> wrote:

>
> 2009/8/1 karthik k <[email protected]>:
> > Hi colin
> >
> > On small help
> >
> > below is the code or checking for uniquness
> >
> > def test_check_for_uniqueness_name
> >
> post=County.new(:name=>"mynamed",:description=>"mydesc",:region_id=>"3")
> >     assert post.valid?, "post was not valid #{post.errors.inspect}"
> >
> > post1=County.new(:name=>"sample",:description=>"mydesc",:region_id=>"4")
> >      assert post1.valid?, post1.errors.full_messages
> >     assert_not_nil post1.errors.on(:name)
> >   end
> >
> > when i run unit testing
> >
> > 1) Failure:
> > test_check_for_uniqueness_name(CountyTest) [test/unit/county_test.rb:26]:
> > <nil> expected to not be nil.
> >
>
> You have said in the test that you expect post1.errors.on(:name) not
> to be nil, but the test fails because it is in fact nil.  Why did you
> expect it not to be nil?
>
> Colin
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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