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.159 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.158 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.157 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.156 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.155 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.154 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.153 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.152 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.151 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.150 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.149 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.148 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.147 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.146 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.145 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.144 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.143 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.142 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.141 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy
trackler-2.2.1.140 tracks/groovy/exercises/scrabble-score/ScrabbleScoreSpec.groovy