Dan Poltawski's Blog

Testing Email Features With MailCatcher

Email is one of those areas of software which is a tricky to get a good test setup and thus rarely gets tested well. In Moodle we have quite a few flags which can be used for development but I’ve never quite felt happy with it. In a previous job we ended up setting up Exim to intercept all messages and write to a file which could be read from a browser. It was pretty complex, a pain to setup and you ended up just looking at the message source.

So I was delighted this week when I came across across MailCatcher via One Thing Well. As it says on their site: MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface.

The instructions are simple:

  1. gem install mailcatcher
  2. mailcatcher
  3. Go to http://localhost:1080/
  4. Send mail through smtp://localhost:1025

So in my Moodle config.php I set: $CFG->smtphosts = 'localhost:1025'; then start doing some email-generating operations and voilĂ :

Everything you need is availble in one place, source view, html view, plain text view – right in your browser. Great job Samuel Cochran!

Excellent Contributing Experience With MediaWiki

Moodle Docs is built upon MediaWiki and this week I’ve been working on upgrading Moodle Docs to the latest MediaWiki release (1.23.0).

I use open source software all the time, but Mediawiki has strong parallels to Moodle1 and it gave me an opportunity for reflection whilst I was doing the sort of tasks Moodle administrators do; reading release notes, testing customisations and discovering bugs. I became involved in Moodle coming from exactly this situation but it’s been quite a few years since I was far enough removed to consider the experience objectively.

I’ve long held the view that making the process clear and responses prompt & encouraging is the key to the successfully converting first-time contributors into long time contributors.2 Mediawiki have nailed this experience in the last few hours:

Great job MediaWiki! I saw the emails this morning (Saturday) and was excited to respond to your feedback.

  1. Being a PHP based web application (though clearly the site profiles and functionality is dramatically different to Moodle)

  2. It was exactly that experience which lead me to stick around in Moodle.

  3. I have used gerrit with Mahara before, so may have had a head start..

Notifying the End of Phpunit Executions on OSX

Whilst integrating issues into Moodle it’s a multiple times per day occurrence to run phpunit tests on the whole Moodle codebase. Each day we add more and more tests and so the time taken to run these tests increases gradually. I’m not one for sword fighting on wheely chairs, so whilst waiting for phpunit tests to run I’ll generally move onto another task, then frequently i’d forget completely that the phpunit run was going on in the background and not know what the phpunit output was showing me, need to run the tests again and fall into the same trap!

In order to resolve this situation I was inspired by Brett Terpstra’s post about using the ruby gem terminal-notifier to send messages to Mountain Lion’s notification center and decided to use this to remind me of phpunit executions.

After installing terminal-notifier and using Bret’s finished.rb script I added a bash function for phpunit:

function phpunit() {
    vendor/bin/phpunit $@
    if [[ $? == 0 ]]; then
        finished "phpunit OK"
        finished "phpunit FAILED"

In order that I don’t miss a phpunit run I’ve configured the notifications to be ‘Alert style notifications’ (configured in OS X Preferences > Notifications > terminal-notifier) which works great, the only remaining issue is there does not seem to be a way to dismiss alerts using keyboard shortcuts.

Moved to Octopress

It’s becoming a bad habbit, but I’ve switched the blog engine for this blog again. I’ve moved from wordpress to Octopress (which itself is a wrapper around jekyll).

I’m sorry if you received all the posts duplicated in your RSS reader (or indeed if you don’t see anything). I tried to configure redirects and the RSS feed to prevent duplicates from appearing, but it appears this is a dark art, and I failed (at least with Google Reader).

I was getting sick of maintaining wordpress – it’s not that difficult, but as I don’t update this blog that much, spending more time keeping the software up to date is more of a chore. Octopress is a static blogging engine, I author the posts as text files (in markdown) and it generates static html files for the blog. This means I don’t have to worry about software maintenance and also don’t need a fancy server stack to host it.