-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sammi-jo's HOTBOOK (nodes) #28
base: master
Are you sure you want to change the base?
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
|
lib/book.rb
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file's a neat idea!
@available = rooms.clone | ||
@room_rate = room_rate | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better name is BookingManager
. Book
sounds like I should be able to turn pages and get an author.
lib/book.rb
Outdated
attr_reader :reservations, :hotel, :blocks | ||
|
||
def initialize(hotel) # expects a dependency injection (HotBook::Hotel.new) | ||
@hotel = hotel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
spec/book_spec.rb
Outdated
expect{book.new_block(daterange, rooms)}.must_raise HotBook::BlockConflictError | ||
end | ||
|
||
it "cannot overlap or conflict with an existing reservation" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions