Archive for May, 2007

Capistrano and Solaris

Recently I’ve been using Capistrano to deploy projects to Solaris. One client uses a Joyent Accelerator (OpenSolaris) and another (University of Virginia) uses Solaris 5.8. The Accelerator is great as it has ZFS, the new Solaris Services, speed, etc. But Solaris is not the same as Linux or FreeBSD when it comes to certain common utilities and this has caused me problems on both servers.

ln

The main culprit is ln. Capistrano use ln -nfs all over the place to make soft links. Unfortunately, the version in Solaris’s /usr/bin does not remove existing soft links with this command. Oy. My first response was to rewrite the tasks like :symlink and :on_rollback to add rm -rf in front of the link command. After forgetting to do this once or twice in new deploy scripts, I posted to the TextDrive forums. Someone mentioned that the Blastwave version of ln (gnu’s version) worked. Well I’m using Blastwave (and you should too), but I don’t remember seeing that. It turns out that gnu’s ln is in /opt/csw/gnu/, not /opt/csw/bin/.

So I just needed that in front of my path, but when Capistrano logs in through ssh, it doesn’t pick up either /etc/profile or ~/.profile. (I don’t have links handy, but apparently this depends on how bash was compiled.) There are two ways of dealing with this. You can add a path to your ssh config (here’s some info), but I prefer making the change in /etc/default/login. I want the Blastwave stuff to take precedence all the time.

Advertisements

More on Should

I was reading a post to Rails Studio mailing list today when I came across this:

If you’re using mocha/stubba, you can say:
@user_notifier.expects(:deliver_activation).never

If you’re using flexmock, you can say:
flexmock(@user_observer).should_receive(:deliver_activation).never

Which would I rather use? Disregarding the frameworks, if you read my previous post, you know the answer: use the active verb! expects is far preferable to should_receive.

Hackety Hack: the Manifesto

_why has started a new and interesting project: Hackety Hack: the Manifesto. The accompanying blog is http://hackety.org/.

BDD: We shouldn’t use "Should"

I like behavior driven development. Even though I still using Ruby and Rails built-in testing framework, I write test names descriptive of behavior.

But I have stopped using should.

Should has become a bunch of noise in BDD that needs to be expunged. What’s wrong with test_should_move_resource_lower_and_return_to_edit_exhibit? One alone is fine, but to read a bunch of should phrases over and over is mind-numbing:

test_should_require_email_on_signup
test_should_require_password_confirmation_on_signup
test_should_require_password_on_signup
test_should_remember_me

What a lot of noise! Who wants to keep hearing the word “should” in their head over and over? Or writing it over and over? Not me!

Use the Active Verb!

So how do I write my test names? Using the active verb:

test_moves_resource_lower_and_returns_to_edit_exhibit
test_requires_email_on_signup
test_requires_password_confirmation_on_signup
test_requires_password_on_signup
test_remembers_me

Much easier to read, the ugly repetition of should is gone, and the method names are shorter. Recently, at Rails Edge in Reston, VA, Jim Weirich gave a test-first presentation where he used active verbs instead of should. I went up after and thanked him profusely.


Pages

Categories

Copyright ©2008-2013 James E Orchard-Hays, All Rights Reserved