Skip to content

Instantly share code, notes, and snippets.

@syshen
Created April 17, 2012 02:38
Show Gist options
  • Select an option

  • Save syshen/2403039 to your computer and use it in GitHub Desktop.

Select an option

Save syshen/2403039 to your computer and use it in GitHub Desktop.
var vows = require('vows'),
assert = require('assert'),
ATM = require('./atm').ATM;
vows.describe("Sufficient cash").addBatch({
"When user owns 100 dollars in the bank": {
"and user wants to withdraw 20 dollars from ATM": {
topic: function() { var atm = new ATM(); atm.deposit(100); return atm.withdraw(20);},
"should get 20 dollars from ATM and leave 80 dollars in the account.": function(result) {
assert (result === 20);
}
}
}
}).export(module);
vows.describe("Insufficient cash").addBatch({
"When user owns 100 dollars in the bank": {
"and user wants to withdraw 20 dollars from ATM": {
topic: function() { var atm = new ATM(); atm.deposit(100); return atm.withdraw(120);},
"should not get any money from ATM and ATM should raise an Error.": function(result) {
assert.throws (result, Error);
}
}
}
}).export(module);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment