When transactional fixtures just won't work (rSpec)

Sat Feb 19 00:00:00 -0500 2011

I had a issue with rSpec some days ago that made me loose a lot of time. When running the suite using “rake spec”, and just after the first example when objects were being created and persisted in the test database, the second and all subsequent examples would fail because of validation errors caused by an unclean test database.

The first configuration line I looked into was the “config.use_transactional_fixtures”, but it was correctly set to true.

After hours trying to catch the issue I finally tracked it down to a “self.class.commit_db_transaction” line of code on a model. I won’t get into why I used this line of code, but enough to say that it wreaks havoc with rSpec’s transactional examples.

A simple solution is to just add a condition such as:

“self.class.commit_db_transaction unless Rails.env.test?”

Beware that this might cause issues with how your code behaves, and it probably won’t work the way you wanted to. Anyway, if you are forcing the commit of the transaction, you might also want to try to find a better way to solve you original problem instead of using it.

Best tool for the job

Fri Feb 18 00:00:00 -0500 2011

I have been thinking lately about stopping the big mental loop about tools and methods and just free myself from that. It’s not that hard. How am I doing that?

- Experiment without prejudice.

Of course, this is very vague and could be applied to many aspects of your life. However, I am suggesting to stop, or at least soften the geeky “holy wars”.

I am a geek and I know. Geeks love to fight over tools and systems. They love to argument about the best, next, bleeding edge tool, gadget, system, whatever. That’s the thing that will allow me to live the life I want – a geek often thinks.

The truth is that, although gadgets, tools and systems do have a big influece on us, they are nothing without a malfunctioning brain.

Let’s take the editors war. You see it everywhere. Emacs is better, vim rocks, you suck, blah blah. I was one of those, in fact.

I have noticed something though. It makes you a person as dumb as the next religious fanatic you met. Your vision is restricted, your lens are blurred. Sure you can get your job done, but you only see from one perspective.

So, free yourself from that.

If you are emacs savyy, try Vim. If you are a Vim wizard, try Emacs. They are good for different things. Emacs is awesome for text editing in general as well as programming, Vim is awesome for programming, because you really have a better time navigating with vim than with emacs.

Textmate? Quite good. I use it sometimes.

Windows? Good for games. OSX? My main OS. Linux? Used it for 5 years, love it.

Org-mode? Awesome piece of software, love it, use it when writing blog pots, brainstorming or to quickly jot-down todo-lists. I used to use it solely for all things GTD, however I started using Things, which ends up being simpler to me for GTD, using it to try to stop my tendency to fiddle with my GTD system all the freaking time. Sometimes I use both. It’s an art after all.

It doesn’t have to be a binary situation. You don’t have to forget emacs if you try vim, and vice-versa. It will probably not happen. There will be also enough reasons to use Textmate. It all depends on what you want to accomplish. You could even end up contributing to both, or even creating cross-libraries.

The most important thing is your time and your happiness. Get things done, be awesome, and don’t be afraid to try something new today.

I am blogging again!

Fri Feb 11 00:00:00 -0500 2011

So, one day I decided to get my hands dirty and ditch my old Wordpress blog. I sat down, started creating a graphical concept for my new site; after a few iterations it kind of looked good. Got the HTML and the whole CSS steup, and put jekyll to work. Nice!

It as a good decision after all. Wordpress, although pretty nice, is bloated and I wanted something that would allow me to poke with design and other modifications more easily. I first though about a Sinatra application, but I didn’t really need something so dynamic.

So, I’ve put the site up, and switched from Dreamhost to a VPS hosting. I was planning to convert my old posts to the new blog, but I think I will just point the old blog to a subdomain.

Anyway, the point is that I’m blogging again, and I have a bunch of drafts to polish and publish, so stay tuned, and thanks for visiting.