3 class InvalidUrlCharsValidatable
4 include ActiveModel::Validations
5 validates :chars, :invalid_url_chars => true
9 class InvalidUrlCharsValidatorTest < ActiveSupport::TestCase
10 include Rails::Dom::Testing::Assertions::SelectorAssertions
12 def test_with_valid_url_chars
13 c = InvalidUrlCharsValidatable.new
15 valid = ["\x7f<hr>", "test@examplecom\x0e-", "s\x1ff", "aa\ufffe",
16 "aa\x0b-", "aa\x08", "\uffff::", "\x00-も対応します", "\x0c*ping",
17 "foo\x1fbar", "foo\x7fbar", "foo\ufffebar", "foo\uffffbar"]
21 assert c.valid?, "'#{v}' should be valid"
25 def test_with_invalid_url_chars
26 c = InvalidUrlCharsValidatable.new
28 invalid = ["Name.", "you;me", "he\"#", "<hr/>", "50%", "good?",
29 "vergrößern,deutsche", "ルシステムに;.も対応します", "輕觸搖/晃的遊戲", "/;.,?%#"]
33 assert_not c.valid?, "'#{v}' should not be valid"