Dennis Laumen We who cut mere stones must always be envisioning cathedrals

The design of iOS 7: simply confusing →

Last monday Apple gave us a sneak peek at iOS 7. This update introduces a bold new visual style for an OS which was, frankly, starting to look a little stale (I still prefer it over its direct competitors though). Although I like the direction Apple took I think the execution is severely lacking. Especially some of the icons are atrocious. What I find interesting about the new look though is the blend of flat design with the use of distinct visual panes. It makes the OS look a bit less sterile than Windows (Phone) 8 for example. iOS 7 does have some of the same downsides as other flat UIs, most notably the buttons which I always fail to recognize as buttons (a problem in most flat designs I've seen to date).

I'm really hoping this was an early look and the final version is way more polished than the peek Apple gave us this week. I think Joshua Topolsky nails it in his article on The Verge:

Apple is showing that it can adapt, borrow, and tweak ideas from the competition, that it can expand what iOS feels and looks like as well as what it can do. The problem now is that it seems to be buckling a bit under the weight of an end-to-end redesign. I'm hopeful that in the next few months, as Apple ramps up for the introduction of new hardware at its fall event, some of the design and functionality issues that have yet to be addressed will be nipped and tucked.

Published by Wercker!

This post was automatically published by Wercker! Wercker is a Dutch startup company which aims to make continuous delivery easy. I just added the Github repository of my Octopress blog, added a YAML file, and clicked some buttons in a slick web interface and my blog posts are automatically published once I push them to GitHub. Nice!

Given-When-Then with Spock

As a recent newcomer to the Groovy and Grails world I only recently discovered Spock. Spock is a testing and specifications framework for Groovy applications (but Java apps are welcome too!).

One of the nice features of Spock is the support for so-called blocks. These blocks start with simple labels like when and then. These labels can even be decorated with a nice description which explains in natural language what the blocks are intended for.

Most of the examples of Spock specifications look like this:

def 'pushing an element on the stack'() { // A nice description of the feature!
    when: // This is an example of a block, it starts here and ends at the next block or the end of the method.

    then: // These blocks don't even have labels, I'll show them in a minute!
    stack.size() == 1
    stack.peek() == elem

Although this is fine in and of itself I prefer to structure my tests according to a user story's acceptance criteria. When doing this I use the now ubiquitous given-when-then scenarios as defined by Dan North and Chris Stevenson.

For example, consider the following user story (the following examples are from Dan North's excellent article I just linked to):

+Title: Customer withdraws cash+
As a customer,
I want to withdraw cash from an ATM,
so that I don’t have to wait in line at the bank.

One of the possible given-when-then scenarios looks like this:

+Scenario 1: Account is in credit+
Given the account is in credit
And the card is valid
And the dispenser contains cash
When the customer requests cash
Then ensure the account is debited
And ensure cash is dispensed
And ensure the card is returned

Unfortunately, I couldn't find anything hinting at support for these scenarios using Spock (like given and and blocks). As per usual, I wasn't looking very well as Spock gives you all the needed information in its documentation. I wrote this blog post anyway just to help the folks googling for "spock given-when-then" and "spock acceptance criteria" (and to remind myself of my own oversight of course!).

Using Spock's aforementioned support for blocks and labels one could implement the scenario above as follows:

def 'Account is in credit'() {
    given: 'the account is in credit' // Look a label! Like I promised earlier!
    def account = new Account() = 2000

    and: 'the card is valid'
    def card = new Card()
    card.valid = true
    card.account = account

    and: 'the dispenser contains cash'
    def dispenser = new Dispenser() = 25000

    when: 'the customer requests cash'
    dispenser.requestCash(100, card)

    then: 'ensure the account is debited' == 1900 // No explicit assertion API, lovely! 

    and: 'ensure cash is dispensed' == 24900

    and: 'ensure the card is returned'

I think it looks and reads great! What I especially like about Spock is that it's really flexible and powerful but has a minimalist syntax.

So, are you still looking for nice specification framework for Groovy (or Java)? Stop looking, go download Spock!