Skip navigation

This post has moved here:
http://codebeef.com/helper-for-testing-model-validation-in-unit-t

Advertisements

6 Comments

  1. Fantastic, does the code have any license or can it be freely used?

  2. Updated to include a license now.

  3. Perfect. And congratulations for your blog, just discovered it but looks fantastic.

  4. I’m experiencing a strange problem while using the snippet.

    It seems to leave in the test db the last record of the valid values passed in the array, so the database is not totally cleaned after running the tests and therefore they are not repeatable.

  5. Yep. To me a similar thing occurred while testing.

    I tried a sequence of 4 validation tests in one test method. After the first run of ‘validation_tester’ the function leaves the object in an invalid state because the invalid tests are done _after_ the valid ones. Just switch the two blocks to leave the object in a valid state at the end.

    Solved the problem for me.

  6. Could we see your create_user method? Maybe your User model as well? I’ve been having a few issues, however I think it’s to do with custom validations module I use for certain validations that I use many times in my application.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: