I know why my code got the Runtime error.
Here’s my code for #get_pass:
def get_guess
print "Guess the code: "
guess = gets.chomp
Code.parse(guess)
end
My code for ::parse:
def self.parse(string)
pegs_arr = string.upcase.chars
unless pegs_arr.all? { |char| PEGS.has_key?(char) }
raise "Invalid colors!"
end
Code.new(pegs_arr)
end
I get this error:
Failure/Error: expect(game.get_guess).to be_instance_of(Code)
RuntimeError:
Invalid colors!
# ./lib/mastermind.rb:21:in `parse'
# ./lib/mastermind.rb:71:in `get_guess'
# ./spec/mastermind_spec.rb:145:in `block (4 levels) in <top (required)>'