Nuovo in questo forum. Cercando di eseguire un test per trovare â
o €
Usando l'asserzione
text.include? "â" , "€"
Ma ottenere errori.
risposte:
3 per risposta № 1Provare:
text.include?("â") || text.include?("€")
O:
/â|€/.match(text)
0 per risposta № 2
Lo farei in questo modo, dal momento che include?
il metodo non accetta un array:
["â", "€"].any? { |char| text.include?(char) }
0 per risposta № 3
Suppongo che tu stia usando Minitest? Puoi usarlo assert_match
:
assert_match(/[â€]/, "text with â")
#=> true
assert_match(/[â€]/, "text with €")
#=> true
assert_match(/[â€]/, "text without")
#=> MiniTest::Assertion: Expected /[â€]/ to match "text without".