Michael MacDonald

Archive for 2009|Yearly archive page

Reasons, Not Excuses

In Personal on December 31, 2009 at 6:00 pm

Earlier this year a friend was considering going to Japan for a conference but he was saying things like “but I couldn’t” and “I can’t afford it”. He was talking himself out of it. I simply said, “focus on reasons not excuses”. Read the rest of this entry »

Pomodoro FTW!

In Business on December 29, 2009 at 8:00 am

Do you pomodoro? It seems to be all the rage. It’s simple but effective, and I highly recommend it.

The Pomodoro Technique is about focus and maintaining that focus. In a sentence, it is about focusing on a single task for 25 minutes straight, no interruptions. Can you do it? For a lot of people, it is pretty hard. Email, twitter, facebook, SMS, and IM all compete for your attention and distract you from your work. People also like to procrastinate. When faced with a difficult task, you’d much rather do something easy and fun. It is common to leave essays and reports to the last minute. Read the rest of this entry »

Leave It In My In-Tray

In Business on December 1, 2009 at 8:16 am

When I first started working in “the enterprise” one of the first things I learnt was how to prioritise. I called it my in-tray method. It worked well but it isn’t something I advocate. In fact, if you find yourself using this method then it’s time to find another job!

The in-tray method worked like this: whenever someone came to give me new work I’d ask them to leave it in my in-tray. Then I would completely ignore it. I would only deal with it if they came back for it. Most of the time they didn’t. Using this technique I could easily figure out what were the real priorities and simply forget the rest.

Read the rest of this entry »

Pickle Tables

In Rails, Testing on November 26, 2009 at 12:12 am

Following on from my original and followup articles on using Pickle with Cucumber, a brand new version of Pickle is now available. Version 0.2.0 now gives you the ability to use Pickle with Cucumber’s multiline step argument tables. This means you can now do the following with Pickle:

Given a company exists
And another company: "rubyflare" exists
And the following people exist:
  | name  | age | employed | company              |
  | Digby | 13  | false    | the first company    |
  | Ethyl | 27  | true     | company: "rubyflare" |
Then the following people should exist:
  | name  | age |
  | Digby | 13  |
  | Ethyl | 27  |
And the 2nd person should be one of company: "rubyflare"'s employees

You can quickly create multiple objects in an easy to read fashion rather than filling your scenarios with multiple lines of “an another user exists …”. As an added bonus you can also use Pickle references within these tables. In the example above, we are creating new people objects and associating them to the companies using the Pickle references for these company objects.

Again, I’ll just point out that the above example required no custom step definitions. I didn’t have to write any step definitions! Pickle takes care of the grunt work leaving you free to focus on your domain specific scenario steps.

Other recent improvements with Pickle include:

  • an email helper for mapping names to email addresses similar to paths
  • its own separate configuration file (pickle.rb) – pickle no longer adds code to features/support/env.rb

I’ve also updated my pickle_example project to the latest version and have added the above example scenario. Feel free to clone it and use it to explore the benefits of using Pickle.

More Pickle Action

In Rails, Testing on November 3, 2009 at 8:00 am

In a previous blogpost I championed the benefits of using Pickle with Cucumber to speed up your BDD. Recently, I was able to contribute back to Pickle in a small way with the following two changes:

This means you can do things like this in your plain text cucumber steps:

Given a user exists with name: "Digby", bank_balance: -43.25

And if you need to, you can also be explicit with the positive sign:
And another user exists with name: "Miranda", bank_balance: +86.50

The extra step definitions allow you to do the following:
Then a user should not exist with name: "Maya"
And the first user should not be one of the last user's debtors
And the last user should not be the first user's creditor

These are the “not” versions of some of the existing default step definitions. I found that I was needing these in my Rails projects and thought they would be good to have in the standard Pickle. Ian White, the creator of Pickle, agreed.

It feels good to contribute back to an open source project, even in a small way, and I encourage you all to try to do so as well.

Pickle my Cucumber!

In Rails, Testing on October 28, 2009 at 8:00 am

If you are using Cucumber then I would highly recommend using Ian White‘s fantastic little add-on called Pickle.

Pickle makes life in the Cucumber world so much easier by providing you with convenient step definitions that take care of common object operations leaving you free to focus on the fun stuff. Combined with the pre-packaged Webrat steps you can dramatically reduce the number of step definitions you need to write.

Read the rest of this entry »

Variables, Scope and Iterators

In Rails on September 30, 2009 at 8:00 am

When I first starting using Ruby I use the for loop to iterate over arrays. A colleague recommended I use the each iterator instead. Why? Check this out… Read the rest of this entry »

Look Ma, No Notes

In Business on September 23, 2009 at 8:00 am

Here’s a challenge for you… don’t take a pen or paper to your next meeting! Just focus on paying attention instead. Read the rest of this entry »

Push Back, Say No

In Business on September 9, 2009 at 8:00 am

I know it’s hard to say it but you can do it. You’re a smart cookie. Let’s try it together…

NO!

Good. That was easy. Let’s try a real example…

Sorry for the late notice but can you drop everything and implement this new whizz-bang feature by the end of the day?

YES!

What?! Read the rest of this entry »

Testing Sphinx with Cucumber

In Rails, Testing on September 2, 2009 at 8:00 am

For awhile, all of my Cucumber features that involved search were marked as TODO. The search worked but I had no integration tests for it because the default setup of Cucumber uses the transactional fixtures setting to run each scenario inside of a transaction to ensure that the database starts in the same known state for each scenario. Unfortunately ThinkSphinx won’t work with this setup. Thankfully, Brandon from opensoul.org wrote up a great post on how to modify your Cucumber setup to get it working.

Further to Brandon’s post, here’s how I’ve incorporated running search features with Cucumber… Read the rest of this entry »

Follow

Get every new post delivered to your Inbox.