Conversation
…ng repository and all commits are gone :(
HotelWhat We're Looking For
|
| expect(@reservations.length).must_equal(1) | ||
| end | ||
|
|
||
| it "raises an error if the room is not available" do |
There was a problem hiding this comment.
Your room here is still available so the ArgumentError is not being raised. This is a good start on testing the double-book issue.
| # unless room_availability(date_range.check_in, date_range.check_out).include?(room) | ||
| # raise ArgumentError, "The room you've selected is not available for these dates." | ||
| # end | ||
| reservation = Hotel::Reservation.new(room, date_range) |
There was a problem hiding this comment.
No check that the room is already reserved.
| def initialize(check_in, check_out) | ||
| @check_in = check_in | ||
|
|
||
| if check_out < check_in |
There was a problem hiding this comment.
You're checking this twice, here and with the total_stay method. A little odd. Also this if statement doesn't check to see if the dates are equal, but your total_stay method did.
| return total_nights | ||
| end | ||
|
|
||
| def date_check(date) |
There was a problem hiding this comment.
This method is a little vaguely named. I suggest naming it within_range to tell if a date is within the DateRange.
| return valid_date | ||
| end | ||
|
|
||
| def daterange_check(check_in, check_out) |
There was a problem hiding this comment.
This method is also a little misleading, I would call it overlap and pass another DateRange instance to compare. If this is the method you're using and you don't expect users to use date_check directly, I would also make that method private.
| def initialize | ||
| @reservations = [] | ||
| @block_reservations = [] | ||
| end |
There was a problem hiding this comment.
I suggest also keeping rooms as an array of numbers and setting it with your hotel_rooms method, so you don't have to repeatably call that method.
|
|
||
| describe 'date check method' do | ||
| it 'returns true if checked date is within daterange (false if not)' do | ||
| expect(@test_daterange.date_check(Date.new(2019,3,12))).must_equal(true) |
There was a problem hiding this comment.
You should also check the start_date and end_date and check to see date_check on those dates.
|
|
||
| describe 'daterange check method' do | ||
| it 'returns true if checked date is within daterange (false if not)' do | ||
| expect(@test_daterange.daterange_check(Date.new(2019,3,12),Date.new(2019,3,14))).must_equal(true) |
There was a problem hiding this comment.
Similar to the above, check the edge cases, date ranges that end on the start date of your date_range and another that starts on the end_date.
Then try some overlaps.
| [*1..20].each do |room| | ||
| @frontdesk.book_reservation(room, Hotel::DateRange.new(Date.new(2019,3,15),Date.new(2019,3,18))) | ||
| end | ||
| expect(@frontdesk.room_availability(Date.new(2019,3,15), Date.new(2019,3,18))).must_equal([]) |
| expect(@frontdesk.res_by_date(Date.new(2002,3,15)) ).must_be_instance_of(Array) | ||
| end | ||
|
|
||
| it "returns array of all booked reservations" do |
There was a problem hiding this comment.
You should also test that it has the given reservations.
|
Hi Chris!
I think I might have misunderstood the Hotel Revisted project. I submitted
my project when it was due and thought that we were supposed to make
changes even though we didn’t receive feedback, to start the break week
refactor project. I commented out the original submission for my project
and I was working on the refactor with date ranges today under the
impression that it was break week homework. If you look at the original
commit, that was my original submission going into wave 3. Is it possible
for you to take a look at it?
…On Sun, Mar 24, 2019 at 3:45 PM Chris M ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In spec/reservation_manager_spec.rb
<#33 (comment)>:
> + end
+
+ describe "book reservation method" do
+ before do
+ @Reservations = []
+ @test_range = Hotel::DateRange.new(Date.new(2019,3,11), Date.new(2019,3,15))
+ end
+
+ it "stores booked reservations in reservations array" do
+ res1 = @frontdesk.book_reservation(1, @test_range)
+ @Reservations << res1
+
+ ***@***.***).must_equal(1)
+ end
+
+ it "raises an error if the room is not available" do
Your room here is still available so the ArgumentError is not being
raised. This is a good start on testing the double-book issue.
------------------------------
In lib/reservation_manager.rb
<#33 (comment)>:
> + @Reservations = []
+ @block_reservations = []
+ end
+
+ def hotel_rooms
+ rooms = [*1..20]
+ return rooms
+ end
+
+ # basic reservation methods
+ def book_reservation(room, date_range)
+ # raising the error but test says nothing was raised
+ # unless room_availability(date_range.check_in, date_range.check_out).include?(room)
+ # raise ArgumentError, "The room you've selected is not available for these dates."
+ # end
+ reservation = Hotel::Reservation.new(room, date_range)
No check that the room is already reserved.
------------------------------
In lib/date_range.rb
<#33 (comment)>:
> @@ -0,0 +1,38 @@
+require 'date'
+
+module Hotel
+ class DateRange
+ attr_reader :check_in, :check_out
+
+ def initialize(check_in, check_out)
+ @check_in = check_in
+
+ if check_out < check_in
You're checking this twice, here and with the total_stay method. A little
odd. Also this if statement doesn't check to see if the dates are equal,
but your total_stay method did.
------------------------------
In lib/date_range.rb
<#33 (comment)>:
> + else
+ @check_out = check_out
+ end
+
+ if total_stay <= 0
+ raise ArgumentError, "Invalid date range provided."
+ end
+
+ end
+
+ def total_stay
+ total_nights = (check_out - check_in).to_i
+ return total_nights
+ end
+
+ def date_check(date)
This method is a little vaguely named. I suggest naming it within_range
to tell if a date is within the DateRange.
------------------------------
In lib/date_range.rb
<#33 (comment)>:
> + raise ArgumentError, "Invalid date range provided."
+ end
+
+ end
+
+ def total_stay
+ total_nights = (check_out - check_in).to_i
+ return total_nights
+ end
+
+ def date_check(date)
+ valid_date = (date >= @check_in && date < @check_out)
+ return valid_date
+ end
+
+ def daterange_check(check_in, check_out)
This method is also a little misleading, I would call it overlap and pass
another DateRange instance to compare. If this is the method you're using
and you don't expect users to use date_check directly, I would also make
that method private.
------------------------------
In lib/hotel_block.rb
<#33 (comment)>:
> @@ -0,0 +1,64 @@
+module Hotel
+ class HotelBlock
+ attr_reader :room, :check_in, :check_out, :cost, :reservations, :hotel
Looks like you got started here, but didn't get far.
Just one observation, I think the hotel instance method is unneeded. You
should have something to keep track of the rooms in the block however.
------------------------------
In lib/reservation.rb
<#33 (comment)>:
> @@ -0,0 +1,23 @@
+require 'date'
+
+module Hotel
+ class Reservation
+ attr_reader :room, :date_range, :cost
+
+ def initialize(room, date_range, cost: 200)
+ @room = room
+ @date_range = date_range
+ @cost = cost
+
+ end
+
+ def total_cost
+ if cost == 200
Why this if statement here? Why not just use the value of cost?
------------------------------
In lib/reservation_manager.rb
<#33 (comment)>:
> @@ -0,0 +1,74 @@
+require 'date'
+
+module Hotel
+ class ReservationManager
+ attr_reader :reservations, :block_reservations
+
+ def initialize
+ @Reservations = []
+ @block_reservations = []
+ end
I suggest also keeping rooms as an array of numbers and setting it with
your hotel_rooms method, so you don't have to repeatably call that method.
------------------------------
In spec/date_range_spec.rb
<#33 (comment)>:
> + end
+
+ it "raises an Argument Error if the check in date is the same as the check out date" do
+ expect{Hotel::DateRange.new(Date.new(2019,3,11), Date.new(2019,3,11))}.must_raise ArgumentError
+ end
+ end
+
+ describe 'total stay method' do
+ it 'calculates the total stay' do
+ ***@***.***_daterange.total_stay).must_equal(4)
+ end
+ end
+
+ describe 'date check method' do
+ it 'returns true if checked date is within daterange (false if not)' do
+ ***@***.***_daterange.date_check(Date.new(2019,3,12))).must_equal(true)
You should also check the start_date and end_date and check to see
date_check on those dates.
------------------------------
In spec/date_range_spec.rb
<#33 (comment)>:
> + ***@***.***_daterange.total_stay).must_equal(4)
+ end
+ end
+
+ describe 'date check method' do
+ it 'returns true if checked date is within daterange (false if not)' do
+ ***@***.***_daterange.date_check(Date.new(2019,3,12))).must_equal(true)
+ ***@***.***_daterange.date_check(Date.new(2019,3,14))).must_equal(true)
+ ***@***.***_daterange.date_check(Date.new(2019,3,20))).must_equal(false)
+ ***@***.***_daterange.date_check(Date.new(2019,3,15))).must_equal(false)
+ end
+ end
+
+ describe 'daterange check method' do
+ it 'returns true if checked date is within daterange (false if not)' do
+ ***@***.***_daterange.daterange_check(Date.new(2019,3,12),Date.new(2019,3,14))).must_equal(true)
Similar to the above, check the edge cases, date ranges that end on the
start date of your date_range and another that starts on the end_date.
Then try some overlaps.
------------------------------
In spec/reservation_manager_spec.rb
<#33 (comment)>:
> +
+ end
+
+ describe 'room availability method' do
+ it "returns available rooms" do
+ [*1..5].each do |room|
+ @frontdesk.book_reservation(room, Hotel::DateRange.new(Date.new(2019,3,15),Date.new(2019,3,18)))
+ end
+ ***@***.***_availability(Date.new(2019,3,15), Date.new(2019,3,18))).must_equal([*6..20])
+ end
+
+ it "returns empty array if all rooms are booked" do
+ [*1..20].each do |room|
+ @frontdesk.book_reservation(room, Hotel::DateRange.new(Date.new(2019,3,15),Date.new(2019,3,18)))
+ end
+ ***@***.***_availability(Date.new(2019,3,15), Date.new(2019,3,18))).must_equal([])
👍
------------------------------
In spec/reservation_manager_spec.rb
<#33 (comment)>:
> + describe "search reservation by date method" do
+ before do
+ @frontdesk.book_reservation(1,
+ Hotel::DateRange.new(Date.new(2019,3,5), Date.new(2019,3,9)))
+ @frontdesk.book_reservation(1,
+ Hotel::DateRange.new(Date.new(2019,4,11), Date.new(2019,4,12)))
+ @frontdesk.book_reservation(5,
+ Hotel::DateRange.new(Date.new(2019,3,5), Date.new(2019,3,8)))
+ @res_list = @frontdesk.res_by_date(Date.new(2019,3,7))
+ end
+
+ it 'returns an empty array if there are no reservations during selected date' do
+ ***@***.***_by_date(Date.new(2002,3,15)) ).must_be_instance_of(Array)
+ end
+
+ it "returns array of all booked reservations" do
You should also test that it has the given reservations.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#33 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ad3zmYVX3swJmv2leCbw2_VhE33ZOdRHks5vZ__vgaJpZM4b5Ljf>
.
|
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions