-
Notifications
You must be signed in to change notification settings - Fork 28
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
oo-ride-share - Liz and Hannah #10
base: master
Are you sure you want to change the base?
Conversation
…ps. Tests driver will be unavilabable during drive
…nd time spent plus average rating cannot be completed with in progress trip
Ride ShareWhat We're Looking For
|
passenger = find_passenger(user_id) | ||
|
||
available_drivers = @drivers.find_all { |driver| driver.status == :AVAILABLE && driver.id != user_id} | ||
raise ArgumentError, 'No available drivers' if available_drivers == [] |
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.
Minor issue: Shouldn't be indented
|
||
def add_trip_in_progress(trip) | ||
@status = :UNAVAILABLE | ||
@driven_trips << trip |
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.
Why not call add_driven_trip
instead?
end | ||
|
||
def net_expenditures | ||
return (super - total_revenue) |
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.
👍
end | ||
|
||
# latest drive developed for wave 4 | ||
def latest_drive |
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.
Very clever method, you're not assuming the most recent trip is the last one in the array. That's good!
return @drivers.find { |driver| driver.id == id } | ||
end | ||
|
||
def request_trip(user_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 is well done, but it's a bit long. You could break it into some helper methods doing the tasks of:
- Selecting an available driver
- Creating a new trip
@@ -58,5 +72,39 @@ | |||
expect(trip.passenger.id).must_equal 9 | |||
end | |||
end | |||
|
|||
it 'calculates the net expenditure of all trips for the user' do |
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 test this with a person with no trips.
OO Ride Share
Congratulations! You're submitting your assignment!
Comprehension Questions
User
andDriver