Using gets.chomp.downcase in initialize method in ruby. Test failing in TDD -
i trying create test , code. test failing , don't know why.
this test:
gem 'minitest' require 'minitest/autorun' require 'minitest/pride' require_relative '../lib/guess_evaluator' class guessprocessor < minitest::test def test_right_length player_guess = guess.new assert_equal 4, player_guess.user_answer.size end
this actual code:
class guess attr_reader :user_answer def initialize(user_answer = gets.chomp.downcase) @user_answer = user_answer end
when run test, don't chance input response when code creates new guess object. shouldn't gets.chomp.downcase called? why or why not? when run minitest, fails , don't have chance give in input.
we expect tdd test tests same cases. then, can modify code confidence, because tests write still passing. @ tdd testing don't come in manualy data.
then, alter player_guess = guess.new
player_guess = guess.new('aaaa')
, test should pass.
ruby tdd
No comments:
Post a Comment