import spock.lang.Specification

class ScramblerTest extends Specification {
	def scrambler
  def FINNISH = "finnish"
  def CAE = "cae"

	def setup() {
		scrambler = new Scrambler()
	}
	
	def "canary"() {
		expect:
		  true == true
	}
	
	def "scrambled word has same length"() {
		expect:
		  scrambler.scramble(FINNISH).length() == FINNISH.length()
	}

	def "scrambled word is different"() {
		expect:
		  scrambler.scramble(FINNISH) != FINNISH
	}
	
	def "scramble word is not repeated"() {
		expect:
		  scrambler.scramble(FINNISH) != scrambler.scramble(FINNISH)
	}
	
	def "score for perfect match"() {
		expect:
		  13 == scrambler.score(CAE, "ace")
	}
	
	def "score excess characters"() {
		when:
		  scrambler.score(CAE, "aace")
		then:
		  def ex = thrown(RuntimeException)
		  ex.message == "Too many letters"
	}
}