I have a few test cases, using unit test, I am new to testing but I don’t understand why, if fixtures are loaded and validations are in place (in my case, I am testing that identical objects should not be saved to the database) – and I know that it works, because doing the test through the UI gives the right behavious, but the test does not behave as the actual application does, and should…
I have a few test cases, using unit test, I am new to testing but I don't
understand why, if fixtures are loaded and validations are in place (in my
case, I am testing that identical objects should not be saved to the
database) -- and I know that it works, because doing the test through the UI
gives the right behavious, but the test does not behave as the actual
application does, and should...
collections(:one) will get you an object that is already in the
database, calling save on it will just update it, not insert a
duplicate. Assuming that there is no other fixture with the same name
as collections(:one), there is no reason why it shouldn't be valid.
Interesting, I thought I had to do a collections(:one).find for it to be taken out of the database, according to the documentation… but i did notice, and my next question was going to be, why do I get an error when doing the find method in the test?
So, I guess it is not true that in order to get the values from the fixture you do this: “collections(:one)” ?
And in order to get the values from the db you do this instead: “collections(:one).find” ?