Skip to content

Instantly share code, notes, and snippets.

@joques
Created January 9, 2012 13:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save joques/7e45d6884ce2d32e933d to your computer and use it in GitHub Desktop.
Save joques/7e45d6884ce2d32e933d to your computer and use it in GitHub Desktop.
zombie = require('zombie')
assert = require('assert')
browser = new zombie.Browser()
describe 'user authentication', ->
it 'should not accept an empty password', ->
browser.visit "https://localhost:3000/sessions/new", {debug: true}, (err, brs, status) ->
brs.fill "username", "fitz", ->
brs.fill "password", "", ->
brs.pressButton "Sign In", ->
assert.equal(brs.body.username, "fitz")
assert.equal(brs.body.password, "")
assert.equal(brs.location, "https://localhost:3000/sessions/new")
it "should not accept an empty username", ->
browser.visit "https://localhost:3000/sessions/new", {debug: true}, (err, brs, status) ->
brs.fill "username", "", ->
brs.fill "password", "fitzpass1", ->
brs.pressButton "Sign In", ->
assert.equal(brs.body.username, "")
assert.equal(brs.body.password, "fitzpass1")
assert.equal(brs.location, "https://localhost:3000/sessions/new")
it "should accept neither an empty username nor a password", ->
browser.visit "https://localhost:3000/sessions/new", (err, brs, status) ->
brs.fill "username", "", ->
brs.fill "password", "", ->
brs.pressButton "Sign In", ->
assert.equal(brs.body.username, "")
assert.equal(brs.body.password, "")
assert.equal(brs.location, "https://localhost:3000/sessions/new")
it "should take both a username and a password", ->
browser.visit "https://localhost:3000/sessions/new", {debug: true}, (err, brs, status) ->
brs.fill "username", "fitz", ->
brs.fill "password", "fitzpass2", ->
brs.pressButton "Sign In", ->
assert.equal(brs.body.username, "fitz")
assert.equal(brs.body.password, "fitzpass2")
assert.equal(brs.location, "https://localhost:3000/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment