Conversation
…itialization and checking to see that length is < 0" "
…ude? method in date_range class & test
…th updated tests that pass. currently working on overlap tests, some of which are breaking...
HotelWhat We're Looking ForTest Inspection
Code Review
Overall FeedbackGreat work overall! You've built your first project with minimal starting code. This represents an incredible milestone in your journey, and you should be proud of yourself! Overall, your code is very neat, logical, and flows well together! I feel that your code is nice, straightforward, and concise. I truly feel confident in your solid grasp on programming fundamentals based on what I see in your project submission. I think that your choices in how you implemented the Overall, your tests are extremely well-organized and have all of the correct parts and syntax (with great I have a couple of other suggestions for how the tests can be improved-- they're minor and actionable and left as comments on your code, so let me know if you have questions on those! Overall, I think that your project looks GREAT! I think there are a feeew bugs, and I think that your tests can improve by becoming more detailed. However, as I mentioned before, I think that your project shows that you can navigate and write your way around a larger project-- well done |
| def date_overlap?(other) | ||
| return (check_in...check_out).cover?(other.check_in) || | ||
| (other.check_in...other.check_out).cover?(check_in) || | ||
| (other.check_in...other.check_out) == (check_in...check_out) |
lib/reservation.rb
Outdated
| class Reservation | ||
| attr_reader :check_in, :check_out, :room | ||
| attr_accessor :date_range | ||
| def initialize(date_range, room = nil, block_reference = nil ) |
There was a problem hiding this comment.
I like your optional arguments a lot! :) :) :) Keep this up!
lib/reservation_maker.rb
Outdated
| date_range = Hotel::Date_Range.new(check_in, check_out) | ||
| @blocks.each do |block| | ||
| if !block.date_range.include?(check_in) | ||
| raise ReservationError, "Date range is not included in existing block!" |
There was a problem hiding this comment.
Hm, this code reads to me like "Check every reservation. If the date_range made above with our proposed check_in and check_out overlaps with any reservation's check_in and check_out, then we should raise a ReservationError." Does this mean that an error will be raised if Room No. 1 has an overlapping reservation, even if Rooms 2-20 are available? In either case, this section of the code doesn't have a unit test, so it's hard for me to check at the moment.
test/block_test.rb
Outdated
|
|
||
| describe "add block to list of blocks" do | ||
| it "returns a list of all blocks" do | ||
| block_array = @reservation_maker.add_block(@block) |
There was a problem hiding this comment.
Because this Act step is about a method that exists in the ReservationMaker class (aka @reservation_maker.add_block), I would probably move this test to the ReservationMaker test!
test/block_test.rb
Outdated
|
|
||
| describe "reserve in block" do | ||
| it "reserves a room inside of a block" do | ||
| @block_reservation = @reservation_maker.reserve_from_block(@check_in, @check_out) |
There was a problem hiding this comment.
Same as above: Because this Act step is about a method that exists in the ReservationMaker class (aka @reservation_maker.reserve_from_block), I would probably move this test to the ReservationMaker test!
test/block_test.rb
Outdated
| @block_reservation = @reservation_maker.reserve_from_block(@check_in, @check_out) | ||
| expect(@block_reservation).must_be_kind_of Hotel::Reservation | ||
| end | ||
| it "raises an exception for a date range not in a block" do |
test/block_test.rb
Outdated
| it "raises an exception for a date range not in a block" do | ||
| @reservation_maker.add_block(@block) | ||
|
|
||
| other_check_in = Date.new(2019-8-01) |
There was a problem hiding this comment.
Watch out -- Ruby interprets this technically as "Make a new Date with the value of 2019-8-1, aka Jan 01, 2010"!
test/reservation_maker_test.rb
Outdated
| it "is a list of reservations" do | ||
| check_in = @date | ||
| check_out = @date + 4 | ||
| reservation = @reservation_maker.reserve_room(check_in, check_out) |
There was a problem hiding this comment.
To test this add_reservation method in isolation, you probably don't need to call reserve_room as part of the Arrange step, you probably can just make a new instance of Reservation! Let me know if that feels confusing
|
|
||
| expect(reservation_list).must_be_kind_of Array | ||
| reservation_list.each do |reservation| | ||
| reservation.must_be_kind_of Reservation |
There was a problem hiding this comment.
it's unclear from this test, but reservation_list is going to be an empty array here! To set this test up properly, it probably would be best if we made sure that @reservation_maker had some reservations made as part of the Arrange before we check the result of reservations_lookup
| date_range = (check_in...check_out) | ||
|
|
||
| room_list = @reservation_maker.available_rooms(date_range) | ||
| expect(room_list).must_be_kind_of Array |
There was a problem hiding this comment.
Hm, I wish this test checked the length of room_list too!
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions