test/test_rps.rb in PlayRockPaperScissorsGame-1.4.4 vs test/test_rps.rb in PlayRockPaperScissorsGame-1.4.5
- old
+ new
@@ -34,15 +34,15 @@
end;
def testPlay(winning_score)
while @player_score < winning_score && @computer_score < winning_score
puts "Player score: #{@player_score}, " +
"Computer score: #{@computer_score}, Ties: #{@ties}";
- player = PrivateVars.player_choice;
+ player = PrivateMethods.player_choice;
computer = Constants::COMPUTER_CHOICES.sample;
puts "\nPlayer chooses #{player.to_s.downcase}";
puts "Computer chooses #{computer.to_s.downcase}";
- case PrivateVars.player_outcome [player, computer]
+ case PrivateMethods.player_outcome [player, computer]
when :WIN
puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
@player_score += 1;
when :LOSE
puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round";
@@ -52,21 +52,21 @@
@ties += 1;
end;
end;
puts "\nFinal score: player: #{@player_score}, " +
"computer: #{@computer_score} (ties: #{@ties})";
- case PrivateVars.final_outcome(@player_score, @computer_score)
+ case PrivateMethods.final_outcome(@player_score, @computer_score)
when :WIN
puts "Player wins!";
when :LOSE
puts "Computer wins!";
else
puts "It's a tie!";
end;
gets;
end;
private;
- module PrivateVars
+ module PrivateMethods
class << self
def player_choice
loop do
print "Choose rock (r), paper (p) or scissors (s): ";
choice = gets.chomp.downcase;