2009/8/4 karthik k <[email protected]>:
> 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 do not top post, insert your question in the right place in
other peoples responses. It is much easier then to follow the thread.
You have not answered my previous questions.  See below.

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

You still have not answered this question - in the test shown why did
you expect post1.errors.on(:name) to be not nil?.  When you reply
please put your answer after here so that we can see what you are
replying to:

Also you have not replied to a previous question I asked:
> 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

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