Integration Testing in Rails 1.1

I must have been asleep at the keyboard the first time I read Jamis article on Integration Testing in Rails 1.1. as it didn’t register as being so promising that it was worth a second look.

You can find the full description on Jamis the { buckblogs :here }.

This is going to be an invaluable tool to test my Rails applications. True, it won’t catch the Javascript problems, but it will help find a lot of the integration issues between the various pages and help me exercise all critical use cases. As you may know, no single testing technique can catch all problems (it is really the combination of all techniques working in tandem that help), and this one is going to be a very important one. And we all know that if adding a test is that easy, then there is no excuse for not doing it ;)

In fact, I’m quite excited at the prospect of giving it a test drive! Thanks Jamis!

3/15 update: and if you can’t wait, you can read Damien Tanner’s article on the subject.

Now I just need to figure out how to play with the trunk without breaking my current installation. I’ll cover that when I get to it.

update #2: scratch my previous comment, there is a good description on how to use the trunk, a.k.a. EdgeRails on rubyonrails.com.

Release 0.2 of BookmarkIt! Sidebar Plugin for Typo

Well, version 0.1 was shortlived. There was a critical difference between running with WEBrick and running in production environment with fastcgi.
The value of env[“REQUEST_URI”] did not contain “http://host”. So I found a quick solution and we’ll see if there is a better solution tomorrow.

Current solution consists of replacing

@article_url = request.env[“REQUEST_URI”]

with

@article_url = ‘http://’+request.env[“HTTP_HOST”]+
  request.env[“REQUEST_URI”]
  if @article_url.eql?(@article_url.gsub(/http:/,”).gsub(/HTTP:/,”))

You live and learn…

bookmarkit-0.2.zip and
bookmarkit-0.2.tgz

Release 0.1 of BookmarkIt! Plugin for Typo

First release (0.1) of BookmarkIt! for typo. Check back for new releases here on blog.nanorails.com

BookmarkIt! is a sidebar plugin for typo. With it, you can let people directly bookmark your blog, or an article dependending on the context. Try it for yourself on the right side of this page.

Installation
uncompress into a temporaty location and move the components and public directory onto your typo installation. On all OS I know, this will add the files in the right location. Then next time you go in the Sidebar section of Typo, you will be able to drag and drop the BookmarkIt! Item onto your Active items. Set the desired title and select the desired services, and then Publish your changes

Compatibility
Tested with typo revision 884. Should work with Typo 2.6.

Not all bookmarking services have been tested yet. I believe that the pages where I got the format for the links to be accurate, but I transcription could be flowed. Only the ones I had an account with. Post a comment on blog.nanorails.com if something doesn’t work.

Download the zip or the tgz file.

Upgrading from SwitchTower to Capistrano

Upgrading/switching from SwitchTower to Capistrano is easy if you follow this recipe (for linux):

sudo gem uninstall switchtower (remove all versions)
sudo gem install capistrano

And for each of your projects:

cap -A .   # don’t forget the period, and keep your deploy.rb
rm lib/tasks/switchtower.rake
svn rm lib/tasks/switchtower.rake
svn add lib/tasks/capistrano.rake
svn commit -m “Capistrano upgrade”

Installing readline on Kubuntu

Running script/console provides the delightful answer:

/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require’:
no such file to load – readline (LoadError)

Turns out that Kubuntu doesn’t have the curses libraries.

Here’s the begining of a solution

apt-get install libncurses5-dev libreadline5-dev (Ubuntu/Debian)

Then recompile the readline extension and go from there.

cd ext/readline
ruby extconf.rb
make
sudo make install

Read more

A better alternative to killall

On my host, severall other users are running other rails applications.

So, when using “rake deploy” while using Capistrano (used to be called SwitchTower before someone objected in infringed on their trademark), the default “killall -9 dispatch.fcgi” is trying to kill other processes that do not belong to me. This creates a problem near the end of the deploy command and it returns a failed status. In this case this is harmless, but… your brain has a tendency to learn to ignore errors when running deploy. Next time you get a real error, it might take you a while to realize that the error wasnt caused by the “killall” command. There is a better alternative where you can filter on the user: pkill.

So in deploy.rb, I’ve replace the

run “killall -9 dispatch.fcgi”

by

run “pkill -9 -u #{user} ruby”

on my config, the processes don’t show up as dispatch.fcgi, but as ruby dispatch.fgci

And, now, bliss is upon us:”rake deploy” completes with no error

Once I get more than one app hosted, I’ll figure out how to get Reaper to work.

The train is leaving the station!

Let’s get this train on the rails and off to some new and exciting adventures. I discovered rails a month ago and I have been dabbling in it ever since. I had been exposed to ruby a while back, but never got interested, and that’s a shame. Now I’m a few trains behind the curve.

This will be a chronicle of my progress, I’ll highlight what I found interesting, post things that I believe could benefit others (See the Quid Pro Quo Section).

Join along for the ride!

Pascal

PS: Note to self: we’ll see how long that train analogy sticks around ;)