-
Notifications
You must be signed in to change notification settings - Fork 45
&&: Kate Pond #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
&&: Kate Pond #22
Conversation
|
Hahaha... okay so maybe I have an excessive amount of commits. I committed whenever I thought that I had finished a thought. I will attempt to bundle better. In the future, I may commit tests and code together instead of the test, then the code, then all the refactoring. :shrug #design p.s. I know that some of my tests are still failing... darn!! |
Grocery StoreWhat We're Looking For
|
| all_customers.each do |customer| | ||
| if id == customer.id | ||
| return customer | ||
| elsif id == "first" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really in the requirements, but interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahaha thanks!
lib/order.rb
Outdated
| class Order | ||
| attr_reader :id, :products | ||
| attr_reader :id | ||
| attr_accessor :products |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not need to be an attr_accessor
| # act | ||
| Grocery::Order.all | ||
| # assert | ||
| Grocery::Order.all.must_be_kind_of Array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also check that every element is an Order
| # act | ||
| Grocery::Order.all[-1].id | ||
| # assert | ||
| Grocery::Order.all[-1].id.must_equal CSV.read('support/orders.csv', 'r')[-1][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever
specs/order_spec.rb
Outdated
| #arrange | ||
| # N/A | ||
| # act | ||
| Grocery::Order.find("first") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to find the first Order of the file by the ID field of that order.
Something like: Grocery::Order.find(1)
lib/online_order.rb
Outdated
|
|
||
| module Grocery | ||
| class OnlineOrder < Order | ||
| attr_reader :id, :customer, :products, :status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this class inherits from Order, you don't need to define an attr_reader for id and products because they inherit them from Order.
|
|
||
| #self.find should come from Grocery::Order | ||
|
|
||
| def self.find_by_customer(customer_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method always raises the ArgumentError, you should return order_array (empty if no order has that customer or if the customer has orders it should return an array of those orders.
| # act | ||
| Grocery::OnlineOrder.all | ||
| # assert | ||
| Grocery::OnlineOrder.all.must_be_kind_of Array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again make sure all the elements are OnlineOrder objects
Grocery Store
Congratulations! You're submitting your assignment.
Comprehension Questions
raise ArgumentError?raise ArgumentErrorcreates a better user experience. So when an invalid entry is given, the user is alerted instead of given nothing or an error they don't understand..all&.findmethods class methods? Why not instance methods?.all&.findmethods class methods we are able to use them for all instances instead on just one instance.