Nowy na tym forum. Próba uruchomienia testu w celu znalezienia â
lub €
Za pomocą asercji
text.include? "â" , "€"
Ale dostaję błędy.
Odpowiedzi:
3 dla odpowiedzi № 1Próbować:
text.include?("â") || text.include?("€")
LUB:
/â|€/.match(text)
0 dla odpowiedzi nr 2
Zrobiłbym to w ten sposób, ponieważ include?
Metoda nie przyjmuje tablicy:
["â", "€"].any? { |char| text.include?(char) }
0 dla odpowiedzi № 3
Zakładam, że używasz minitestu? Możesz użyć assert_match
:
assert_match(/[â€]/, "text with â")
#=> true
assert_match(/[â€]/, "text with €")
#=> true
assert_match(/[â€]/, "text without")
#=> MiniTest::Assertion: Expected /[â€]/ to match "text without".