Skip to content

Instantly share code, notes, and snippets.

@antony
Created March 8, 2012 16:50
Show Gist options
  • Save antony/2002027 to your computer and use it in GitHub Desktop.
Save antony/2002027 to your computer and use it in GitHub Desktop.
Spock Formatting
def "The 'recommended' way"() {
when:
enabled = true
firstName = "Luke"
lastName = "Daley"
createButton.click()
then:
at ShowPage
}
def "The 'readable' way"() {
when:
enabled = true
firstName = "Luke"
lastName = "Daley"
createButton.click()
then:
at ShowPage
}
@antony
Copy link
Author

antony commented Mar 8, 2012

Note that #2 (readable) is my suggestion, #1 (recommended) is the official way.

@robfletcher
Copy link

an artificially unreadable example; add a blank line before line 7

def "The 'recommended' way"() {
    when:
    enabled = true
    firstName = "Luke"
    lastName = "Daley"
    createButton.click()

    then:
    at ShowPage
}

@antony
Copy link
Author

antony commented Mar 8, 2012

@robfletcher
Copy link

Well, we all know @ldaley can't write nicely formatted code. That doesn't prove anything

@antony
Copy link
Author

antony commented Mar 8, 2012

How do you 'like' on this damn thing? :)

@antony
Copy link
Author

antony commented Mar 8, 2012

P.S. I still think indentation (although I realise switch/case statements which use labels also aren't indented) is more readable. The labels munge into the set-up/assertions otherwise

@robfletcher
Copy link

Yeah, I get the rationale. I think of the block labels as comments with some magic. Making them look like blocks could be misleading.

@paulfairless
Copy link

We currently use the 'readable' style, but have to admit I now use the 'recommended' way outside of Sky. Not sure if that's just because I don't have to fight IntelliJ

@tomaslin
Copy link

tomaslin commented Mar 8, 2012

Is it recommended because that is just the default in IntelliJ? O No me gusta.

@antony
Copy link
Author

antony commented Mar 8, 2012 via email

@tomaslin
Copy link

tomaslin commented Mar 9, 2012

@antony
Copy link
Author

antony commented Mar 9, 2012

Nice. Saves me doing it! Thanks @tomaslin

@bodiam
Copy link

bodiam commented Oct 29, 2015

Label indents. In 2011. Crazy people.

@antony
Copy link
Author

antony commented Aug 29, 2016

Indents ftw @bodiam!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment