lundi 19 janvier 2015

having difficulty understanding ruby minitest

I am using minitest for the first time and I am having trouble understanding how to write my first test method. Can anyone assist in helping me understand what I should be testing in the below Player method get_name?



class Player
def get_name(player)
puts `clear`
center("#{player}, whats your name bro/ladybro?")
@name = gets.chomp
until @name =~ /\A[[:alnum:]]+\z/
center("you can do a combination of alphanumeric characters")
@name = gets.chomp
end
end
end


This is what I have in my test file, I was thinking I am just suppose to test the regex to make sure it takes alpha and numeric characters.



class TestPlayer < Minitest::Test
def test_get_name
describe "get_name" do
it "should allow an input of alphanumeric characters" do
assert_match(/\A[[:alnum:]]+\z/, "test_string123")
end
end
end
end


but when I run the tests, nothing seems to happen, I would imagine I am suppose to have 1 assertion.



Run options: --seed 10135

# Running:

.

Finished in 0.001565s, 638.9776 runs/s, 0.0000 assertions/s.

1 runs, 0 assertions, 0 failures, 0 errors, 0 skips


can anyone assist in demonstrating how I should write a test for this scenario? thanks.


Aucun commentaire:

Enregistrer un commentaire