Conversation
HotelWhat We're Looking For
|
| @@ -0,0 +1,29 @@ | |||
| require "spec_helper" | |||
| end | ||
|
|
||
| def self.load_all | ||
| return @reservations || [] |
There was a problem hiding this comment.
You're trying to use in instance variable in a class method. That doesn't make sense.
This method looks like it should be reading from the CSV file and returning a list of Reservations.
| def initialize(check_in_date, check_out_date) | ||
| self.class.validate_date(check_in_date) | ||
| self.class.validate_date(check_out_date) | ||
| validate_date_range(check_in_date, check_out_date) |
There was a problem hiding this comment.
You're not saving check_in_date or check_out_date in instance variables here... so why have the class.
I think you're missing
@start_date = check_in_date
@end_date = check_out_dateOn the other hand if you don't' want to make instances of DateRange I suggest making it a module and have no initialize method.
| end | ||
|
|
||
| # I can access the list of reservations for a specific date, so that I can track reservations by date | ||
| def list_reservations(date:) |
| end | ||
|
|
||
| # I can get the total cost for a given reservation | ||
| def total_cost(reservation_id:) |
There was a problem hiding this comment.
I suggest the cost of a reservation is best served in the Reservation class. It seems like your manger class is doing too many jobs.
| check_in_date: "2019-03-10", | ||
| check_out_date: "2019-03-15", | ||
| discount_rate: 0.10) | ||
| expect { |
There was a problem hiding this comment.
You should also have edge-case tests, like reserving a room on the same day a previous reservation ends, and on the same day one begins.
You should also test reserving two different rooms on the same dates.
| check_in_date: "2019-04-12", | ||
| check_out_date: "2019-04-15") | ||
| expect(reservation_manager.list_reservations(date: "2019-03-14").length).must_equal 2 | ||
| expect(reservation_manager.list_reservations(date: "2019-04-14").length).must_equal 1 |
There was a problem hiding this comment.
You should also check the values inside those arrays.
| reserve_04_15_04_20 | ||
| expect(reservation_manager.find_available_rooms(check_in_date: "2019-03-20", check_out_date: "2019-03-22").length).must_equal 20 | ||
| expect(reservation_manager.find_available_rooms(check_in_date: "2019-04-17", check_out_date: "2019-04-19").length).must_equal 19 | ||
| expect(reservation_manager.find_available_rooms(check_in_date: "2019-03-10", check_out_date: "2019-04-19").length).must_equal 18 |
There was a problem hiding this comment.
I would also check that at least one of the expected available rooms is available and that a room that is booked is not listed as available.
| expect(reservation_manager.find_available_rooms(check_in_date: "2019-03-08", check_out_date: "2019-03-22").length).must_equal 19 | ||
| end | ||
|
|
||
| it "returns the right number of rooms when check_in_date and check_out_date range is within reserved rate range " do |
| end | ||
| end | ||
|
|
||
| describe "validate_id method" do |
There was a problem hiding this comment.
validate_id seems like it should be a private helper method and thus not tested directly.
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions