Skip to content

Instantly share code, notes, and snippets.

@searls
Created November 19, 2011 15:28
Show Gist options
  • Save searls/1378962 to your computer and use it in GitHub Desktop.
Save searls/1378962 to your computer and use it in GitHub Desktop.
SecretTreasure = (config) ->
somethingWasTyped: ->
if $('.secret').val() == config.secret
$('.treasure').removeClass('hidden')
describe "Secret Treasure!", ->
SECRET = "whizbang"
beforeEach ->
@$secretInput = inject(el: 'input', cssClass: 'secret')
@$treasure = inject('treasure').addClass('hidden')
@subject = SecretTreasure(secret: SECRET)
describe "#somethingWasTyped", ->
context "when the user figured out the secret", ->
beforeEach ->
@$secretInput.val(SECRET)
@subject.somethingWasTyped()
it "shows the treasure to the user", ->
expect(@$treasure).not.toHaveClass('hidden')
context "when the user was incorrect", ->
beforeEach ->
@$secretInput.val("so wrong")
@subject.somethingWasTyped()
it "does not show the treasure", ->
expect(@$treasure).toHaveClass('hidden')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment