Created
February 5, 2015 16:09
-
-
Save nelantone/1f5f007e9fe349529a60 to your computer and use it in GitHub Desktop.
Paper_scissor_rock_test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Paperscissorsrock | |
def start_game | |
puts | |
puts 'Welcome to the paper, scissors, rock game!' | |
puts | |
puts 'please choose your option paper, scrissors, rock' | |
puts | |
puts "(press ctr-c to quit)" | |
puts | |
sampler | |
end | |
def sampler | |
@option = gets.chomp.downcase | |
@array = ["paper", "scissors", "rock"] | |
@computer_choice = @array.sample | |
resolve_game | |
end | |
def resolve_game | |
puts "------------------" | |
case [@option , @computer_choice] | |
when [ "scissors", "paper"], ["paper", "rock"], ["rock", "scissors"] | |
puts "congrats! You win :D" | |
when [ "paper", "scissors"], ["rock","paper"], ["scissors","rock"] | |
puts "you lose :(" | |
when [ "paper", "paper"], ["rock","rock"], ["scissors","scissors"] | |
puts "draw :)! Try again!" | |
else | |
puts "sorry, write well the option you want (paper,scissors, stone)" | |
end | |
puts "------------------" | |
#start_game | |
end | |
end | |
game = Paperscissorsrock.new | |
game.start_game |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './paper_scissors_rock' | |
describe Paperscissorsrock do | |
it "should give draw" do | |
game = Paperscissorsrock.new | |
game.resolve_game | |
when ["paper","paper"] | |
expect(game.resolve_game).to eq("draw, try again!") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment