Tuesday, February 2, 2010

[Rails] Re: assert_equal behavior

On Feb 2, 3:58 pm, Vishwa Rao <li...@ruby-forum.com> wrote:

>
> I expected the test to fail as there was no record in the database and
> the 'find' should return nothing. But it creates a new one and the test
> is a success. I do not see any code for creating new record or save. So
> why is it creating a new record?
> I do not understand assert_equal behavior , can someone please explain?

assert_equal is a simple beast - it just compares the two arguments
you pass to it. What you actually don't understand is how the test
database is setup. In particular if you have a fixtures file for a
table (as you appear to do) rails will create rows in that table for
you based on your fixtures file.

Fred

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

No comments:

Post a Comment