-
Notifications
You must be signed in to change notification settings - Fork 2
GreenBOX Project _STHOMAS #1
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
…es rent_movie method writtent
…le method still failing
CheezItMan
left a comment
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.
Overall pretty good waves 1-2.
You do need more work on available_movies and rent_movie and the tests.
You have a good number of commits and good commit messages and the code is overall pretty well done. I'd like you to first look through the MovieReserver class and the two incomplete methods and then work on the tests with Andrew if you can.
| if (date >= @start_date) && (date < @end_date) | ||
| return true | ||
| else | ||
| date < @start_date || date >= @end_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.
You don't need this 2nd conditional since if it's not inside you can return false.
if (date >= @start_date) && (date < @end_date)
return true
else
return false
end|
|
||
|
|
||
| # `overlaps(other_date_range)` - This method takes another date range as a parameter and returns `true` if the date ranges overlap. | ||
| def overlaps(other_date_range) |
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.
👍
| @actors = actors | ||
| end | ||
|
|
||
| movie = GreenBox::Movie.new(4,'Happiness','Fox',actors:['Denzel Washington', 'LL Cool J']) |
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 can take this line out
| def initialize | ||
| @movies = MovieReserver.load_movies | ||
| @rentals = [] | ||
| @date_range = GreenBox::DateRange.new(Time.parse('2018-08-08'),Time.parse('2018-08-09')) |
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 @date_range is unnecessary since there isn't one daterange needed by the system. Instead each Rental will have it's own DateRange
| publisher = line[2] | ||
| all_actors = line[3] | ||
| actors_names = all_actors.split(':') | ||
| actors = {actors: actors_names} |
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 could also make this:
actors = actors_namesAnd just use an array instead of a has containing one array.
lib/movie_reserver.rb
Outdated
| # them with the ones in the movie list | ||
| # | ||
|
|
||
| if @rentals.length > 0 |
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.
Since you have the previous if statement, you don't need this one.
lib/movie_reserver.rb
Outdated
| @rentals.each do |movie| | ||
| movie.id | ||
| if @movies.include(movie.id) | ||
| available_movies = @movies.delete(movie.id) |
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.
Since delete will remove any matching movies from the@movies array permanently, you would do better to:
- Make a copy of
@movies - Use
.rejectto remove movies that match the given id - Return that resulting list of movies
| end | ||
|
|
||
| # * `cost`: This method will return the cost of the rental. A movie rental will cost $3.0 per night. The customer is **not** charged for the day the movie is checked in. So a movie checked out on August 8th and checked in August 10th would cost $3.00 * 2 days = $6.00 | ||
| def cost |
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.
👍
specs/movie_reserver_spec.rb
Outdated
| it 'will not include rented movies' do | ||
| date_range = GreenBox::DateRange.new(Time.parse('2018-08-08'), Time.parse('2018-08-09')) | ||
| reserver.rent_movie('Crazy Rich Asians', date_range, 'Ada Lovelace') | ||
| #reserver.rent_movie('Crazy Rich Asians', date_range, 'Ada Lovelace') |
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.
If you're going to comment this out, you'll need to manually add a rented movie to the system.
reserver.rentals << Rental.new('movie title', Time.parse('2018-08-08'), Time.parse('2018-08-09'))
specs/movie_reserver_spec.rb
Outdated
| # assert | ||
| ## the rent_movie methods will return | ||
|
|
||
| @rental.rent_movie(id = 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.
It might be easier just to give the title of the movie, although you could do it by ID. However you'll need a MovieReserver instance.
You are right these tests below need work. You might try replicating some of the format of the tests written for you.
…nt_movies and available_movies
… 2 test failrures and 1 test error
CheezItMan
left a comment
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.
I left a few more suggestions here, your tests are not bad, and they are catching some bugs in your code.
Some strong improvement here.
| xit 'cannot rent a movie already rented' do | ||
| # TODO Your Code goes here | ||
|
|
||
| it 'cannot rent a movie already rented' 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.
This is a well written test! 👍
Nice work!
| # * `rent_movie(movie_title, date_range, customer_name)`: This method will attempt to reserve a movie with the given title for the given date range. If the movie is not available in that range the method should raise a `StandardError`. | ||
|
|
||
| def rent_movie(movie_title, date_range, customer_name) | ||
| @movies.each do |movie| |
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.
As your test shows, this isn't working because it always rents a movie as long as the movie is in the inventory.
If I can make a suggestion:
- See if the list of
available_movieshas this movie title, you can use.eachorfind_byto do so. - If so, you can create a rental,
- add it to the list
- return the rental
|
|
||
| #Assertions - something that has changed that tells | ||
| #us we have the expected result | ||
| expect(rental).wont_be_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.
This is good, you also might want to test that
expect(rental.movie.title).must_equal title (the title of the movie being rented is right.
You can also test that the number of rentals has increased by one (so the length of rentals increased by one).
| it 'can rent multiple movies with the same title' do | ||
| # TODO Your Code goes here | ||
|
|
||
| movie_reserver = GreenBox::MovieReserver.new |
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.
Nicely done!
| # @movies is a MovieReserver object that contains movies. | ||
| available_movies = [] | ||
| @movies.each do |movie| | ||
| if @rentals.date_range == date_range |
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 part is not quite right. @rentals is an array and so doesn't have a date_range attribute.
Instead you should:
- make a copy of the
movieslist - then loop through your
rentalsarray and remove any movies who have a rental that conflicts.
You can look up the select method to find movies that don't have a given ID or object id.
Last updates on the GreenBox and tests to be added and updated this afternoon.