Conversation
… clock, regrets choices.
HotelWhat We're Looking For
|
| @@ -0,0 +1,18 @@ | |||
| { | |||
There was a problem hiding this comment.
Maybe include the .vscode folder in .gitignore
| @@ -0,0 +1,6 @@ | |||
| module Errors | |||
| ROOMS = (1..20).to_a | ||
| module Hotel | ||
| class Registry | ||
| attr_accessor :reservations, :okay_rooms |
|
|
||
| def initialize | ||
| @reservations = [] | ||
| @okay_rooms = [] |
There was a problem hiding this comment.
@okay_rooms probably doesn't need to be an instance variable. You could make it a local variable in available? which could return a list of rooms which are available.
Making it an instance variable which several methods are playing with and making it an accessor opens you up to side effects.
| @check_in = Date.parse(check_in) | ||
| @check_out = Date.parse(check_out) | ||
| @room = room | ||
| end |
There was a problem hiding this comment.
I suggest detecting the overlapping of dates here or in another DateRange class to simplify your Registry class.
|
|
||
| 3. Consider splitting out another class hereabout or thereabout ... we didn't mean to get this, er, aerodynamic and it might backfire when the blocks come in, or in terms of readability. | ||
|
|
||
| 4. Figure out what the heck 3 lines the tests aren't covering and cover them. No newline at end of file |
There was a problem hiding this comment.
😆 However maybe a refactor dealing with design instead.
| expect(@test_registry.available?("2019/07/19", "2019/07/25")).must_equal(true) | ||
| end | ||
|
|
||
| it "pushes available room numbers to okay_rooms array" do |
There was a problem hiding this comment.
This test gets into the internal workings of your class that the user shouldn't have access to. Better not not give the user access to okay_rooms
|
|
||
| it "reservations array contains all bookings" do | ||
| expect(@test_registry.reservations.length).must_equal(2) | ||
| end |
There was a problem hiding this comment.
You should also test that you can book a room with a reservation that starts on the same day the previous one ended.
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions