Sha256: 0f2778ce01c672c32b33ef1cbe33113f72c67786277bc1f8fbc3d79dfa694fd4

Contents?: true

Size: 1.03 KB

Versions: 134

Compression:

Stored size: 1.03 KB

Contents

@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
import spock.lang.*

class ScrabbleScoreSpec extends Specification {

    def 'lowercase letter'() {
        expect:
        ScrabbleScore.scoreWord('a') == 1
    }

    def 'uppercase letter'() {
        expect:
        ScrabbleScore.scoreWord('A') == 1
    }

    def 'valuable letter'() {
        expect:
        ScrabbleScore.scoreWord('f') == 4
    }

    def 'empty input'() {
        expect:
        ScrabbleScore.scoreWord('') == 0
    }

    @Unroll
    def 'score for word #word should be #expectedScore'() {
        when:
        def score = ScrabbleScore.scoreWord(word)

        then:
        score == expectedScore

        where:
        word                         | expectedScore
        'at'                         | 2
        'zoo'                        | 12
        'street'                     | 6
        'quirky'                     | 22
        'OxyphenButazone'            | 41
        'pinata'                     | 8
        'abcdefghijklmnopqrstuvwxyz' | 87
    }

}

Version data entries

134 entries across 134 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.138 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.137 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.136 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.135 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.134 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.133 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.132 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.131 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.130 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.129 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.128 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.127 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.126 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.125 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.124 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.123 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.122 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.121 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.120 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy