Skip to content

Instantly share code, notes, and snippets.

@adamjleonard adamjleonard/BankAccountSpec.swift Secret
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.