-
Notifications
You must be signed in to change notification settings - Fork 40
Time - Sharon Cheung #27
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
base: master
Are you sure you want to change the base?
Conversation
HotelSection 1: Major Learning Goals
Section 2: Code Review and Testing Requirements
Section 3: Feature Requirements
Overall Feedback
Additional 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! I am particularly impressed by the way that you designed your classes and methods to have single responsibility. You've done a great job working through some tricky logic. I do see some room for improvement around the thoroughness of your tests. It is important to test multiple nominal and edge success and failure cases to ensure that your code correctly handles different scenarios. Keep up the hard work! Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
| # start_date and end_date should be instances of class Date | ||
| # new data range and reservation created | ||
| # first available room assigned to the new reservation | ||
| raise ArgumentError.new("They are not the valid Date class for start_date and end_date") if (start_date.class != Date || end_date.class != Date) |
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.
Consider putting this exception raising functionality into the DateRange class.
| new_reservation = Reservation.new(resevation_duration, customer_name) | ||
| new_reservation.cost | ||
| reservation_id = @reservation_list.length + 1 | ||
| if self.available_rooms(start_date, end_date)[0] == nil |
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.
Minor note: consider finding the available room before creating a new reservation and using this available room when instantiating the new reservation.
| if occupied_rooms_list.empty? | ||
| return @room_list | ||
| else | ||
| available_rooms_list = @room_list - occupied_rooms_list |
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.
Consider the fact that you don't necessarily need to check if occupied rooms are empty. @room_list - occupied_rooms_list will return the correct array whether or not occupied_rooms_list is empty. Reducing the number of tests makes your code faster and more concise.
| @@ -0,0 +1,95 @@ | |||
| require_relative 'test_helper' | |||
|
|
|||
| describe "Hotel Controller" 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.
These tests do a good job testing the nominal cases. It is important to provide numerous test cases for each method, testing possible edge cases. For instance, what do reserve_room and 'available rooms` return when there are no available rooms?
|
|
||
| expect(hotel_block).must_be_kind_of Hotel::BlockReservation | ||
| expect(@front_desk.reservations(Date.new(2020,06,20)).length).must_equal 5 | ||
| expect{@front_desk.create_hotel_block(Date.new(2020,06,20), Date.new(2020,06,25), 10)}.must_raise ArgumentError |
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.
It looks like you are testing an edge case here. Nice work! You should put this in it's own it block so it is clear what you are testing.
| end | ||
| end | ||
|
|
||
| describe "check_hotel_block_list_availability" 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.
It is hard for me to see from you tests whether you've accounted for the situation where a reservation is trying to be made for a room that is reserved in a block. This, and other cases where regular reservation and block reservations may overlap should be explicitly tested for.
| it "will reserve room within the hotel block" do | ||
|
|
||
| # Arrange & Act | ||
| @front_desk.create_hotel_block(Date.new(2020,06,20), Date.new(2020,06,25), 5) |
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.
Minor syntax note: tab in the content of an it block.
| expect(@date_range_two.overlap?(@data_range)).must_equal false | ||
| end | ||
|
|
||
| it "will return true if the time is overlapping" 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.
These are good nominal case tests. It is important to thoroughly test the different ways that dates can overlap. See this pseudo code from the design-scaffold
describe "overlap?" do
before do
start_date = Date.new(2017, 01, 01)
end_date = start_date + 3
@range = Hotel::DateRange.new(start_date, end_date)
end
it "returns true for the same range" do
start_date = @range.start_date
end_date = @range.end_date
test_range = Hotel::DateRange.new(start_date, end_date)
expect(@range.overlap?(test_range)).must_equal true
end
xit "returns true for a contained range" do
end
xit "returns true for a range that overlaps in front" do
end
xit "returns true for a range that overlaps in the back" do
end
xit "returns true for a containing range" do
end
xit "returns false for a range starting on the end_date date" do
end
xit "returns false for a range ending on the start_date date" do
end
xit "returns false for a range completely before" do
end
xit "returns false for a date completely after" do
end
end
xdescribe "include?" do
it "reutrns false if the date is clearly out" do
end
it "returns true for dates in the range" do
end
it "returns false for the end_date date" do
end
end
Assignment Submission: Hotel
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection