Toxic Elephant

Gem for memory_test_fix

Posted by matijs Sun, 27 Jun 2010 21:10:00 GMT

In some of my Rails projects, I have been a contented user of the memory_test_fix plugin. However, I rather dislike the use of Rails plugins, because I find updating them later on rather difficult, and I don’t like including external libraries in my own source tree (hence, I don’t like the practice of vendoring gems much either). When the concept of ‘gem plugins’ was introduced, I created a fork on github and created the necessary files to build the plugin as a gem, and have Rails properly load it.

Somehow I never got around to seeing if all this actually worked. However, recently I revisited an old project that I never quite finished, updated it to Rails 2.3.8, and decided to try replacing the memory_test_fix plugin code it included with a simple call to config.gem. It worked fine.

After incorporating a patch to allow the use of in-memory databases for any environment (use for development and production is of course not recommended), the gem is now at version 0.1.3, and has been pushed to gemcutter.

From the README:

Install the gem:

gem install memory_test_fix

In your config/environments.rb, use:

config.gem 'memory_test_fix'

In your database.yml, use:

test:
  adapter: sqlite3
  database: ":memory:"

It runs much faster!

This makes me the official maintainer of this gem, which may not be ideal in the long run, since I’m not really the main author of this code. Feel free to ask me for access or to contact me to discuss other options.

Posted in  | Tags , , , ,  | no comments | no trackbacks

I'm Not a Mockist

Posted by matijs Sun, 04 Nov 2007 13:56:00 GMT

Let’s talk about mocking.

It apparently is the hot new thing in Rails land. And like earlier silver bullets, it’s becoming a religion: Acolytes would rather write ten lines to set up a mock object than one to instantiate an actual one.

Honestly, I have tried to understand the benefits of mocking, but I just don’t see them1. Then I thought I would have to write a long article about how mocking is flawed, and would you people please all see sense already. Luckily, Martin Fowler did it for me, and with a lot more objectivity. Go read his Mocks Aren’t Stubs. In addition to explaining the difference between Mocks and Stubs (a difference often overlooked by the religious), he explains why you might not want to use what he calls “mockist testing”.

So, in the spirit of religious tolerance, I can now say: I’m not a Mockist.

My particular reasons?

  • Mockist testing is not DRY: Each class’ behavior is now defined in its code, its unit tests, and each time it is mocked.
  • Mockist testing tests a particular implementation of behavior, making refactoring harder.
  • Mockist testing makes writing your tests more work, inviting you not to test.

Next time you find yourself complaining that setting up your mock objects is such a lot of work, ask yourself: “Am I a Mockist?”. Maybe you’re not.

1 Well, one minor benifit I can see that you can start writing and testing your views before having written your models. I never seem to want to do that anyway, though.

Posted in  | Tags , ,  | no comments | no trackbacks

Disqualified by Advertising

Posted by matijs Thu, 23 Aug 2007 16:36:00 GMT

I was enthousiastic about noobkit for about a week. Finally an alternative to the rough style of Ruby’s standard API documentation.

Until I actually wanted to use it.

Most pages have a full width block of Google ads above the main content. This is just too much. For some methods, the text is one line. The ad block then is five times as big.

I’ll go back to using the old version, thanks.

[Also, the search function is not geared towards API documentation, but instead uses a generic Google-like method. Why not highlight the search results that actually describe the method or methods with the searched name?]

Posted in  | Tags , , ,  | no comments | no trackbacks

Outage

Posted by matijs Mon, 18 Jun 2007 13:13:00 GMT

Last week, I did some work on my website, upgrading to the latest Typo trunk and Rails 1.2, and changing from mod_fcgid to a Mongrel cluster.

Last Friday or so, I rebooted my server. Unfortunately, I had neglected to make the Mongrel cluster start at boot. So for the past weekend, all you have seen here is a Service Temporarily Unavailable message.

Sorry.

Posted in  | Tags , , ,  | no comments | no trackbacks

Toxic Elephant is Matijs van Zuijlen's weblog.

Powered

Categories

Archives