Skip to content

Instantly share code, notes, and snippets.

@adamjleonard
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamjleonard/50ed876bfef183c6cb11 to your computer and use it in GitHub Desktop.
Save adamjleonard/50ed876bfef183c6cb11 to your computer and use it in GitHub Desktop.
class BankAccount {
var balance = 0.00
func deposit(amount: Double) {
balance += amount
}
func withdrawal(amount: Double) {
balance -= amount
}
}
import Quick
import Nimble
class BankAccountSpec: QuickSpec {
override func spec() {
it("starts with a 0.00 balance") {
let account = BankAccount()
expect(account.balance).to(equal(0.00))
}
describe("#deposit") {
it("increases balance") {
let account = BankAccount()
account.deposit(133.70)
expect(account.balance).to(equal(133.70))
}
}
describe("#withdrawal") {
it("decreases balance") {
let account = BankAccount()
account.deposit(133.70)
account.withdrawal(100.00)
expect(account.balance).to(equal(33.70))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment