Conversation
…ion method, tests pass
…method is written
…onflict?(daterange) Pick one, and update both the class method and the method in book.rb that depends on it.
HotelWhat We're Looking For
|
| end | ||
| # Cannot overlap or conflict with existing reservation | ||
| rooms.each do |room_number| | ||
| if room_taken?(daterange, room_number) |
There was a problem hiding this comment.
This will break if ONE room is unavailable in the date range.
Correction
Normally when you're reserving a block of rooms you specify the number and the system picks the rooms. The front Desk doesn't have to individually select them.
When we met, I missed the fact that you're passing in the list of rooms to include in the block as a parameter. I just hadn't consider it at that moment. So your code works, but with a limitation that the user has to specify every room to include in the block, rather than just selecting a group from the available rooms.
| @@ -0,0 +1,24 @@ | |||
| # gems the project needs | |||
| @available = rooms.clone | ||
| @room_rate = room_rate | ||
| end | ||
|
|
There was a problem hiding this comment.
So Block has a set of rooms and a way to remove rooms from the list, and tell if the block conflicts, I feel like it should be able to reserve a room in the block as well, maybe then returning a reservation which your booking system could use to update reservations.
lib/book.rb
Outdated
| # making new reservations and blocks. | ||
| # It includes support methods for determining availability/conflicts. | ||
|
|
||
| class Book |
There was a problem hiding this comment.
Maybe a better name is BookingManager. Book sounds like I should be able to turn pages and get an author.
| attr_reader :reservations, :hotel, :blocks | ||
|
|
||
| def initialize(hotel) # expects a dependency injection (HotBook::Hotel.new) | ||
| @hotel = hotel |
There was a problem hiding this comment.
What is the@hotel variable supposed to do?
|
|
||
| describe "disable method" do | ||
| it "won't alter the rooms array when it executes" do | ||
| block.disable("1") |
There was a problem hiding this comment.
Maybe check that it contained 1 before and then it doesn't after.
| end | ||
| end | ||
|
|
||
| describe "conflict? method" do |
There was a problem hiding this comment.
You should test more varieties of conflicts.
| describe "disable method" do | ||
| it "won't alter the rooms array when it executes" do | ||
| block.disable("1") | ||
| expect(block.available).must_equal ["2", "3"] |
There was a problem hiding this comment.
Also what happens if you try to disable a room twice?
spec/book_spec.rb
Outdated
| end | ||
|
|
||
| it "new reservation edge case" do | ||
| expect{ 21.times { book.new_reservation(shortrange) } }.must_raise HotBook::NoRoomsAvailableError |
| expect{book.new_block(daterange, rooms)}.must_raise HotBook::BlockConflictError | ||
| end | ||
|
|
||
| it "cannot overlap or conflict with an existing reservation" do |
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions