We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Pathname#initialize
1 parent f2bd3d6 commit a2edd25Copy full SHA for a2edd25
1 file changed
test/pathname/test_pathname.rb
@@ -485,6 +485,13 @@ def test_initialize
485
p2 = Pathname.new(p1)
486
assert_equal(p1, p2)
487
488
+ obj = Object.new
489
+ assert_raise(TypeError) { Pathname.new(obj) }
490
+
491
492
+ def obj.to_path; "a/path"; end
493
+ assert_equal("a/path", Pathname.new(obj).to_s)
494
495
obj = Object.new
496
def obj.to_str; "a/b"; end
497
assert_equal("a/b", Pathname.new(obj).to_s)
@@ -495,6 +502,10 @@ def test_initialize_nul
502
assert_raise(ArgumentError) { Pathname.new("a\0") }
503
end
504
505
+ def test_initialize_encoding
506
+ assert_raise(Encoding::CompatibilityError) { Pathname.new("a".encode(Encoding::UTF_32BE)) }
507
+ end
508
498
509
def test_global_constructor
499
510
p = Pathname.new('a')
500
511
assert_equal(p, Pathname('a'))
0 commit comments