Spock Web Console

subscribe to the feed Subscribe
MyFirstSpecv2 (via #spockwebconsole)
tweet this script Tweet

MyFirstSpecv2

Published 2 months ago by lajos with tags spock
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.*

class MyFirstSpec extends Specification {
  
  def "let's play with stack"() {
    given: "an empty stack"
    def stack = new Stack()

    and: "an element"
    def elem = "push me"
    
    when: "we push the element into the stack"
    stack.push(elem)

    then: "the stack is not empty"
    !stack.isEmpty()

    and: "contains only the elemet we pushed"
    stack.size() == 1
    stack.peek() == elem
  }

}