-
-
Save adamjleonard/50ed876bfef183c6cb11 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
class BankAccount { | |
var balance = 0.00 | |
func deposit(amount: Double) { | |
balance += amount | |
} | |
func withdrawal(amount: Double) { | |
balance -= amount | |
} | |
} |
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
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