Conversation
…method to reservation_manager
… test for reservation_dates
…sic instantiation as of right now
…reservation_manager class. Have not written tests yet
…vation method. both test passed test
…for finding list of available rooms for a certain date
…nd code that broke from the change. still need to fix reservation instance test and argumenterror for unavaible rooms test
…on list of rooms. test still not passing
…ake_reservation method to add book_room to current_reservation. still failing tests to add new reservation to current reservations.
…available_rooms_list methods and tests but still not fully running
…coverage. Rest of code depends on the 2 tests
…age (close enought, right?)
HotelWhat We're Looking ForTest Inspection
Code Review
Overall FeedbackGreat work overall! You've built your first project with minimal starting code. This represents an incredible milestone in your journey, and you should be proud of yourself! Good work on this project! I really like how you took ownership of how to keep track of reservations by utilizing a hash and nested arrays. A lot of your tests are cleanly written, too! I think you have a really solid start on this project. That being said, I want to highlight places that I'd want to see this project improve if you had more time. In general, I see two things that concern me:
I would love to make sure that you come out of Unit 1 with more clarity on:
I've added a few comments on some places that I think would be good considerations and questions to muse on. From those comments, I'd love to know what questions come up, too! Let's catch up soon! |
lib/reservation_dates.rb
Outdated
| require 'date' | ||
|
|
||
| module HotelBookings | ||
| class Reservation_Dates |
There was a problem hiding this comment.
Nitpick: Naming convention says this is named ReservationDate for class names-- no underscore, and keep it singular!
| require_relative 'reservation' | ||
|
|
||
| module HotelBookings | ||
| class Reservation_Manager |
There was a problem hiding this comment.
Nitpick: the Ruby naming convention would call this ReservationManager, without the _
lib/reservation_manager.rb
Outdated
| def reservation_list(date) | ||
| unavailable_rooms = [] | ||
| key = 1 | ||
| MAX_ROOMS.times do |
There was a problem hiding this comment.
Is it possible to refactor this MAX_ROOMS.times to @current_reservations.each do |room, reservations|, so that room will always represent the value of the room? (aka below you would use @current_reservations[room])
lib/reservation_manager.rb
Outdated
| def available_rooms_list(date) | ||
| available_rooms = [] | ||
| key = 1 | ||
| MAX_ROOMS.times do |
There was a problem hiding this comment.
Using a .times loop feels awkward, and relying on a variable called key doesn't quite evoke the meaning of what key is. It might be interesting to refactor this to use a .select, since .select will create an array of values that are true in certain conditions (like if @current_reservations at that room excludes the date)
lib/reservation_manager.rb
Outdated
| end | ||
|
|
||
| def reservation_nights(checkin:, checkout:) | ||
| @dates = Reservation_Dates.new(checkin: checkin, checkout:checkout) |
There was a problem hiding this comment.
Instead of using an instance variable @dates, it probably will be fine to keep it as a local variable dates. This is because currently, @dates isn't used outside of this method, and the ReservationManager doesn't need to keep and manage @dates.
lib/reservation_manager.rb
Outdated
| return nights | ||
| end | ||
|
|
||
| def book_room(checkin:, checkout:) |
There was a problem hiding this comment.
this method is long and a little difficult to read. What are you trying to accomplish here? What should this method return? How can we change this name so it's more evocative?
lib/reservation_manager.rb
Outdated
| # key += 1 | ||
| # end | ||
|
|
||
| new_reservation = Reservation.new(customer_name:@customer_name, checkin: checkin, checkout: checkout, room_no: reserved_rooms) |
There was a problem hiding this comment.
Hm, your ReservationManager keeps a list of all reservations in the hash @current_reservations, whose keys are rooms, and whose values are hashes of room number and dates... And this instance of Reservation in new_reservation doesn't get tracked in ReservationManager. Do we need the Reservation class?
lib/room.rb
Outdated
| #create room class | ||
|
|
||
| module HotelBookings | ||
| class Room |
There was a problem hiding this comment.
Feel free to delete this class before submission if it doesn't get used!
test/reservation_manager_test.rb
Outdated
| describe "make_reservation method, makes the reservation" do | ||
| before do | ||
| @new_res = @bookingtest.make_reservation(checkin:'2019-09-01', checkout:'2019-09-03') | ||
| @new_res2 = HotelBookings::Reservation_Manager.new(customer_name: 'Momo') |
There was a problem hiding this comment.
Your tests read a little strangely to me: here -- the value of @new_res2 is an instance of Reservation_Manager. Is there a better name for this variable?
test/reservation_manager_test.rb
Outdated
| end | ||
|
|
||
| it "new reservation is saved in current_reservations" do | ||
| expect{ |
There was a problem hiding this comment.
Using binding.pry before this line here shows me that the value of @current_reservations is nil (this makes sense-- @current_reservations hasn't been defined here yet), and the value of @new_res2 is an instance of Reservation_Manager without any reservations stored on it.
I think that this test will be better if you think about what the Arrange-Act-Assert steps are. We want to arrange an instance of Reservation_Manager and also all the data we will need to make a reservation... Our act will be to call the make_reservation method from that instance of Reservation_Manager, and our assert in this test would be to check the value of .current_reservations saved on the instance of Reservation_Manager, to see if it includes the reservation and reservation data we were expecting. To read the current_reservations instance variable from our instance of Reservation_Manager would need the attr_reader :current_reservations in Reservation_Manager, and to use the syntax reservation_manager.current_reservations in this test.
test/reservation_manager_test.rb
Outdated
|
|
||
| it "new reservation is saved in current_reservations" do | ||
| expect{ | ||
| @current_reservations.has_value?([Date.parse('2019-09-01'), Date.parse('2019-09-02')]) |
There was a problem hiding this comment.
This is a nitpick on syntax: Because this isn't the expect { ... }.must_raise ArgumentError syntax, we just use (), not {}, so expect( ... ).must_equal true
test/reservation_test.rb
Outdated
| expect(@reservation.total_cost).must_equal 440.40 | ||
| end | ||
|
|
||
| it "checks if total_cost rounds 2 decimals" do |
…nged some naming conventions and moved tests to their new test location.
…the program worked better. I know it's not the best (nor how I want it)
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions
*** Forgot to add refactor.txt file. Here are my list of refactors.