Skip to content

Instantly share code, notes, and snippets.

@nelantone
Created February 5, 2015 16:09
Show Gist options
  • Save nelantone/1f5f007e9fe349529a60 to your computer and use it in GitHub Desktop.
Save nelantone/1f5f007e9fe349529a60 to your computer and use it in GitHub Desktop.
Paper_scissor_rock_test
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
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