n.times { code! }

Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, May 03, 2010

i18n gem for mongoid

I have just released my first gem!

It tries to leverage the pain in the ass that is model localization. It's for mongoid in this case, and its a pleasure to use (supposing that it works fine, since it hasn't been tested in a real environment yet).

I won't bother you with the details, since you can see a readme or even check the kind of announcement I made in the mongoid google group.

If you apps uses mongoid and you need to localize your fields, please check it out and test as much as you can. I need feedback to fix broken stuff and add new features.

Friday, February 27, 2009

unit vs. functional tests

Sometimes I find myself thinking about unit tests being useless. Not that really useless, but bothering, at least when compared to functional tests.

In the end, you should really rely on functional tests to check the health of your application, since those are the only tests that are really checking that all your stack works perfectly, top to bottom, that the database schema is ok, and that permissions and data are handled correctly.

You can even add functional tests to an existing (legacy?) system to use them as regression tests, and to be able to refactor parts of the application while knowing that everything is still right, while adding unit tests could be a pain in the ass, and not that useful, really.

Why are unit tests bothering? They are harder to maintain. You usually can change the implementation of some functionality without touching functionals, but you usually have to make changes to your unit tests. I recommend you to abuse stubs to keep the coupling to a minimum, though.

Anyway, when it al comes down to the development itself, it's when unit tests really shine. They allow you to start coding any class without worrying about other classes, thanks to mocks and stubs. They help you to think about communication between your objects or processes or whatever, because you should create your methods or functions simple enough that they can be easily tested. And finally, they are your api documentation. They allow any other developer to learn your application by example.