-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Tom O'Neill rps challenge #2120
base: main
Are you sure you want to change the base?
Conversation
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.
Nice work, bro!
visit("/") | ||
expect(page.status_code).to eq(200) | ||
end | ||
|
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.
Ahh nice to see an example of a test for this
def random_move | ||
ALLOWED_MOVES.sample | ||
end | ||
|
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.
All of these .rb's are so CLEAN, so TIGHT, every function has a clear and distinct role. V tasty.
"paper scissors" => false, | ||
"paper paper" => 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.
Ha much cleaner than mine. I saw some smart ones on codewars I was meaning to implement.
def check_move_allowed(move) | ||
fail 'Incorrect move' if !ALLOWED_MOVES.include?(move) | ||
end | ||
|
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.
So have you implemented this in such a way as it requires the player enters another choice?
expect(game.calculate_result('paper','scissors')).to eq false | ||
end | ||
end | ||
end |
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.
All tests are comprehensive, v nice
<% if @result == nil %> | ||
|
||
It's a draw | ||
|
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.
Oooooo interesting, I totally forgot about how to place if/else logic within the html page. This opens it up a lot. Nice work
<form action="/calculate_results" method="post"> | ||
<button class= "selection" type="submit" value = "rock" name="choice"><img src='rock.png' alt="Rock" width="300" height="500" ></button> | ||
<button class= "selection" type="submit" value = "paper" name="choice"><img src='paper.png' alt="Paper" width="300" height="500" ></button> | ||
<button class= "selection" type="submit" value = "scissors" name="choice"><img src='scissors.png' alt="Scissors" width="300" height="500" ></button> |
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.
Ohhhhh that's why the pics were there :') hahahaa
No description provided.