Closed rdavid1099 closed 7 years ago
Requested changes:
[x] Write tests verifying the following (line 29 in this file shows how to check for output):
[x] Change the default prompt to the empty string "" by default (most common).
[x] Update lib/driver.rb uses of player_input
to use "> " for the prompt. Set a variable in the function for the prompt string (since it is used twice).
[x] Change lowercase
to be true by default (in most cases, it will need to be true).
[x] Update code in ayara folder to use player_input
instead of gets
or gets.chomp
(the one exception is within the BBall
module - leave it as gets
). If you see the type
function anywhere before input, just use an empty string prompt. Note that receiving the player's name must use lowercase
= false.
[x] Update line 24 of lib/util.rb for the correct variable name.
[x] Remove the default behavior in line 25 of lib/util.rb since it's included in the function signature.
Thank you!
Just a heads up, I had to change the test block in util.rb#player_input in order to test the new arguments.
if(ENV['TEST'] == 'rspec')
print prompt
input = gets.chomp
puts "\n" if doublespace
else
Updating Ayara now.
@nskins Requested changes taken care of and ready for review :)
There's one more player_input
in lib/driver.rb for which you should set the prompt. As for the test block of player_input
that you mention above, can you think of some way to DRY the printing of the prompt and the newline? Right now those are repeated, but there's a simpler way to write it.
Everything else is looking good!
This is a bit controversial, so I wanted to check with you before committing and pushing.
input = if(ENV['TEST'] == 'rspec')
print prompt
gets.chomp
else
Readline.readline(prompt, false)
end
puts "\n" if doublespace
The only problem is that prompt
is in two spots (non-DRY). How about this?
print prompt
input = (ENV['TEST'] == 'rspec') ? gets.chomp : Readline.readline('', false)
puts "\n" if doublespace
Nice, @nskins. I like it. It's fixed and pushed.
Thank you! As you can see on the README, I am currently working on writing tests over the entire codebase. Once I've finished, I will have one more task for you, which is to merge your changes into the new codebase. I will let you know when that time comes.
You got it 👍
Hi Ryan, I'll handle the merge conflict myself since I don't want you to worry about all the code I wrote recently (there's a lot). Will let you know about something else you can work on soon.
player_input now versatile enough to be handled throughout the framework.
NOTES:
player_input has three options: prompt, lowercase, and doublespace
Tests added to util_spec to test lowercase functionality.