Conversation
HotelWhat We're Looking For
|
| @@ -0,0 +1,22 @@ | |||
| class Room | |||
There was a problem hiding this comment.
This class seems to mostly serve as a a container for reservations, which might be better served as a feature of your Hotel class.
| room = rooms_available(check_in, check_out).first | ||
|
|
||
| reservation = Reservation.new(check_in, check_out, room) | ||
| @reservations << reservation |
There was a problem hiding this comment.
It's a little awkward that your Hotel and your Room objects both need to track the Reservation. It would be simpler if the Reservation was just stored in Hotel.
| binding.pry | ||
| end | ||
| end | ||
|
|
There was a problem hiding this comment.
You've only tested the initialize method. You should also test:
- That you can make a reservation
- That if you have a reservation in a date range, the next room is selected.
- If all rooms are booked, an error is produced.
- If a reservation ends on the new booking date, the room can be reserved.
| it "calculates the reservation cost correctly" do | ||
| expect(@reservation.cost).must_equal 600 | ||
| end | ||
|
|
There was a problem hiding this comment.
Since it's public, you should also test the nights method.
Plus the during? method.
spec/room_spec.rb
Outdated
| end | ||
|
|
||
| it "raises an error if room number is higher than 20" do | ||
| expect{(Room.new(21))}.must_raise ArgumentError |
There was a problem hiding this comment.
Do you really need to have a test for this here? It makes the Room class harder to reuse.
Should Room raise an error if the number is higher than 20?
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions