Conversation
Bank AccountWhat We're Looking For
This is pretty good, and you seem to understand the core concepts well enough, but there are several places where the details don't quite match what we wanted. Please take some time to go through the inline comments, and feel free to reach out to Jamie or I if you have any questions or want to work through something. |
| end | ||
|
|
||
| def self.find(id1) | ||
| @accounts_array.each do |line| |
There was a problem hiding this comment.
I like the idea of using the accounts loaded in Account.all here in find. But there's a problem - if find is run before all, you get an error! How could you guarantee that all has been run by the time you get here?
| end | ||
|
|
||
| def self.all | ||
| @accounts_array = [] |
There was a problem hiding this comment.
You probably want a class variable (two @s) here. What you'v got is an instance variable defined at the class level, which can act a little weird in some situations. Better to just stick with the class variable, at least for now.
| it "Can find the first account from the CSV" do | ||
| # TODO: Your test code here! | ||
| Bank::Account.all[0].id.must_equal 1212 | ||
| end |
There was a problem hiding this comment.
Since this test is under describe "Account.find", it ought to be using the find method. How might you modify it to test what it says it tests?
| @checks = 0 | ||
| end | ||
|
|
||
| def withdraw(withdraw_amount) |
There was a problem hiding this comment.
It might be cleaner to use super here to call Account#withdraw, and centralize your logic all in one place. In this case Account#withdraw would probably require more parameters, like a fee and a minimum balance.
| # TODO: Your test code here! | ||
| end | ||
|
|
||
| it "Doesn't modify the balance if the account would go below -$10" do |
There was a problem hiding this comment.
It looks like you removed a test here, possibly by accident?
| balance = 100 | ||
| amount = 10 | ||
| account = Bank::CheckingAccount.new(17682, balance) | ||
| 3.times {balance = balance - amount} |
There was a problem hiding this comment.
I like that you used times here to DRY up this code. Good work!
Bank Account
Congratulations! You're submitting your assignment.
Comprehension Questions
raise ArgumentError? What do you think it's doing?.all&.findmethods class methods? Why not instance methods?