Skip to content

Instantly share code, notes, and snippets.

@nathanic
Created November 29, 2012 19:34
Show Gist options
  • Save nathanic/4171294 to your computer and use it in GitHub Desktop.
Save nathanic/4171294 to your computer and use it in GitHub Desktop.
validation test example
(fact "answers get validated"
(let [ctx {:state :composing
:players #{"data" "geordi" "picard"}
:submissions {}
:letters [\S \I \T \M]
;:live? true
}]
(submit-answer ctx "data" "sock it to me")
=> (contains {:submissions {"data" "sock it to me"}})
; you can't copy someone else's answer
(-> ctx
(submit-answer "data" "sock it to me")
(submit-answer "geordi" "Sock It To Me"))
=not=> (contains {:submissions {"geordi" "Sock It To Me"}})
(submit-answer ctx "data" "some invalid stuff that doesn't work")
=not=> (contains {:submissions {"data" "some invalid stuff that doesn't work"}})
(submit-answer ctx "non-player" "whatever")
=not=> (contains {:submissions {"non-player" "whatever"}})
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment