-
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
Stevie Spiegl RPS #2115
base: main
Are you sure you want to change the base?
Stevie Spiegl RPS #2115
Changes from 1 commit
4359d10
1a24ee3
cea74c9
43edfb8
e071a99
392b36c
b136975
3be0405
0736433
8bfb302
23d4805
c1a4456
0a48d3e
af14b6c
7fc16b4
f0c7b17
6ced6bc
598460d
d7f237f
b331630
0162508
737ec52
e8cacd9
82d354a
06a966c
633c77b
ddb2463
5dcf235
c5a6c4f
bb949f7
9d44f07
88bf62a
1353f7a
dae923e
6f8e164
177486c
1c2215f
06e98e2
f3b1de1
1cb42bb
d143894
da77118
db0dba3
2eab430
63b1b62
2d23f71
508234a
a74ace6
66baab1
64d1602
a34292f
10ba08e
b7773b9
1a95f63
72c4d4f
63bb33e
cebb680
852c43f
c252626
0401afd
e0db0da
2d98a80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,4 @@ def engine | |
"You did not choose wisely." | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to see the creation of a WEAPONS constant in this file. Could the |
||
|
||
#replace the strings with a method, either winning_message or losing_message | ||
#each will run sample on an array of three messages | ||
#or use the phrases to suggest another go | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,12 @@ | |
end | ||
|
||
scenario 'player is taken to a new page to start the game' do | ||
sign_in_and_play | ||
sign_in | ||
expect(current_path).to eq('/play') | ||
end | ||
|
||
scenario 'player can see their name on the play page' do | ||
sign_in_and_play | ||
sign_in | ||
expect(current_path).to eq('/play') | ||
expect(page).to have_content('Alien') | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clear, concise, good indentation |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,66 +5,43 @@ | |
|
||
feature 'allows player to play a game of RockPaperScissors' do | ||
scenario 'the player can choose from three buttons' do | ||
sign_in_and_play | ||
sign_in | ||
expect(page).to have_xpath('/html/body/form[1]/input[1]') | ||
expect(page).to have_xpath('/html/body/form[2]/input[1]') | ||
expect(page).to have_xpath('/html/body/div/form/input[1]') | ||
end | ||
#the above is a workaround because I can't seem to check for a link | ||
#in the same way I was able to check for a button before I turned them | ||
#into images... not sure how good it is though because you need to know | ||
#the xpath before writing the tests... | ||
|
||
scenario 'a player can return to the play screen to have another go' do | ||
sign_in_and_play | ||
sign_in | ||
click_on(id='rock') | ||
expect(page).to have_button('Have another go?') | ||
end | ||
|
||
|
||
scenario 'clicking a button takes the player to the winner page' do | ||
sign_in_and_play | ||
sign_in | ||
click_on(id='rock') | ||
expect(current_path).to eq '/battle' | ||
end | ||
|
||
scenario 'rock beats scissors' do | ||
allow_any_instance_of(Computer).to receive(:weapon).and_return(:scissors) | ||
sign_in_and_play | ||
sign_in | ||
click_on(id='rock') | ||
expect(page).to have_content "You chose wisely." | ||
end | ||
|
||
scenario 'paper beats rock' do | ||
allow_any_instance_of(Computer).to receive(:weapon).and_return(:paper) | ||
sign_in_and_play | ||
sign_in | ||
click_on(id='rock') | ||
expect(page).to have_content "You did not choose wisely." | ||
end | ||
|
||
scenario 'scissors beats paper' do | ||
allow_any_instance_of(Computer).to receive(:weapon).and_return(:paper) | ||
sign_in_and_play | ||
sign_in | ||
click_on(id='scissors') | ||
expect(page).to have_content "You chose wisely." | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really clear test scenarios, really enjoyed reading these if I'm honest. Good takeaway for my tests in the future, thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, good testing, well done for using stubs effectively here |
||
|
||
#why no need for srand here in the stubs above? | ||
#what's the difference between stubbing here and the doubling | ||
#in the tests for computer_spec??? | ||
|
||
#would these tests be better off in the model??? | ||
|
||
|
||
|
||
#functionality to add: | ||
|
||
|
||
|
||
#I'd like to route to a different image depending on the result | ||
#but that seems like too much for now... | ||
#credit unsplash photographers | ||
|
||
|
||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
def sign_in_and_play | ||
def sign_in | ||
visit('/') | ||
fill_in 'player', with: 'Alien' | ||
click_on('Submit name!') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
require 'game' | ||
|
||
describe Game do | ||
xit 'paper beats scissors' do | ||
end | ||
xit 'scissors beats rock' do | ||
end | ||
xit 'rock beats scissors' do | ||
end | ||
xit 'two of the same draw' do | ||
end | ||
xit 'displays a congratulatory message if the player wins' do | ||
end | ||
xit 'taunts the player if they lose' do | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty file? I think you left the spec for this somewhere else? Then maybe you could delete this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it would be good to consider what you might have tested in here if you had the time - you could even comment some ideas and come back to it at a later stage when you want to make improvements, especially the logic in Game is an important one. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,4 @@ | |
it "should return player's name" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much better indentation here. Clear class names and tests. Nice one man! |
||
expect(player.name).to eq('Clodius') | ||
end | ||
|
||
xit 'allows a player to choose a weapon' do | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ text-align: center;} | |
<h1>You chose <%= @player_weapon %>...<br></h1> | ||
<h1>Computer chose <%= @computer_weapon %>...<br><h1> | ||
<h1><%= @message %><h1> | ||
<form action='/name_play_again' method='post'> | ||
<form action='/play_again' method='post'> | ||
<button type="submit" style="padding: 5px 10px">Have another go?</button> | ||
</form> | ||
</body> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same again. Takes maybe a day or two to write the code, but people would have to read it an unspecified amount of time |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ h1 {text-align: center; font-family: arial; padding-top: 20px} | |
</style> | ||
|
||
<h1>Enter Name</h1> | ||
<form action='/name' method='post'> | ||
<form action='/play' method='post'> | ||
<input type="text" name="player" style="padding: 5px 15px"><br><br> | ||
<button type="submit" style="padding: 5px 10px">Submit name!</button> | ||
</form> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation.. naughty naughty! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ border='2' name='player_choice' type='submit' id='paper'></> | |
<input type="hidden" name="player_choice" value="paper" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to indent everything! Makes it easier to read for others ;) Maybe even have blank lines between the parts that don't relate i.e. After each form to show where one stops and the other starts (this is only when you know a code review will be done) |
||
</form> | ||
<div style="margin: 0px auto; width: 400; height: 267; overflow: hidden; border: 2px solid black"> | ||
<!-- margin: 0px auto saved me here, nothing else would center the div --> | ||
<form action='/battle' method='post'> | ||
<input type='image' src='https://source.unsplash.com/c18q3myyHLU' width='400' | ||
name='player_choice' type='submit' id='scissors'></> | ||
|
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.
Great file, concise, good use of class names and instance and global variables