Time - Corinna & Nataliya#6
Conversation
OO Ride ShareMajor Learning Goals/Code Review
Testing Requirements
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
SummaryWell done, you hit all the learning goals here. Well done. Take a look at my inline comment, there are a few scenarios from Wave 2 that you didn't update once a driver/passenger could be on an in-progress trip. The existing tests work, but you don't test the methods with an in-progress trip. Otherwise excellent work! |
| describe "net_expenditures" do | ||
| # You add tests for the net_expenditures method | ||
| it "returns the total amount a passenger has spent on their rides [from csv]" do | ||
| trip_dispatch = RideShare::TripDispatcher.new |
There was a problem hiding this comment.
Since this is a test of the Passenger class, it makes more sense to test Passenger independently of Dispatcher, as you can have a Passenger without a dispatcher.
| trips.each do |trip| | ||
| if trip.rating != nil | ||
| finished_trips += 1 | ||
| rating_sum += trip.rating | ||
| end |
There was a problem hiding this comment.
You can also use some enumerables as well to simplify this a bit.
| trips.each do |trip| | |
| if trip.rating != nil | |
| finished_trips += 1 | |
| rating_sum += trip.rating | |
| end | |
| complete_trips = trips.select { |trip| !trip.nil? } | |
| total = complete_trips.reduce(0) do |sum, trip| | |
| sum + trip.cost | |
| end | |
| return total / complete_trips.length.to_f |
| trips.each do |trip| | ||
| unless trip.cost == nil | ||
| if trip.cost > 3 | ||
| total += ((trip.cost.to_f - 1.65) * 0.8) | ||
| else | ||
| total += trip.cost.to_f | ||
| end | ||
| end | ||
| end | ||
| return total |
There was a problem hiding this comment.
Take a look at the above and see if you can identify how to use reduce to simplify this a bit.
| @@ -29,7 +34,7 @@ | |||
| end | |||
|
|
|||
| it "stores an instance of driver" do | |||
There was a problem hiding this comment.
You should also include a test with a trip created without a driver or driver_id and similarly for passenger.
| expect(trip_dispatch.passengers[0].net_expenditures).must_equal 15 | ||
| end | ||
|
|
||
| it "returns the total amount a passenger has spent on their rides [given new information]" do |
There was a problem hiding this comment.
You should also test this with a passenger who is on an incomplete trip.
| @@ -132,5 +132,125 @@ | |||
|
|
|||
| describe "total_revenue" do | |||
There was a problem hiding this comment.
You should also test total_revenue to ensure it works if a driver has an in-progress trip.
Assignment Submission: OO Ride Share
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection