Created
December 7, 2012 03:08
-
-
Save blackcoat/4230448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Clicker</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
</head> | |
<body> | |
<h1>Welcome to Clicker!</h1> | |
<p>You clicked the button <span id="count">0</span> times.</p> | |
<button id="click-me">Click me</button> | |
<script type="text/javascript"> | |
$(function() { | |
$('#click-me').click(function() { | |
$('#count').text( parseInt($('#count').text()) + 1 ); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
should = require 'should' | |
Browser = require 'zombie' | |
browser = new Browser | |
site: "http://0.0.0.0/personal/zombie-test/static/" | |
describe 'Clicker#index specs', -> | |
before (done) -> | |
@appName = "Clicker" | |
browser.visit 'index.html', (e, browser) -> | |
done() | |
it 'uses the app name as the <title>', -> | |
browser.text('title').should.eql @appName | |
it 'says app name in the heading', -> | |
browser.text('h1').should.include @appName | |
it 'displays a click count', -> | |
should.exist browser.query '#count' | |
it 'increments the click count by 1 when button is pressed', (done) -> | |
browser.pressButton "Click me", (error) -> | |
try | |
parseInt(browser.text('#count')).should.eql 1 | |
done() | |
catch e | |
done(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Browser = require 'zombie' | |
browser = new Browser | |
site: "http://0.0.0.0/personal/zombie-test/static/" | |
browser | |
.visit('index.html') | |
.then -> | |
browser.pressButton '#click-me', -> | |
# Want to see this callback fail? Just `throw new Error()` | |
console.log "click count is now #{browser.text('#count')}" | |
.then -> | |
browser.pressButton '#click-me', -> | |
console.log "click count is now #{browser.text('#count')}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment