diff --git a/lib/quix/ext/pathname.rb b/lib/quix/ext/pathname.rb index 57adde2..af026c1 100644 --- a/lib/quix/ext/pathname.rb +++ b/lib/quix/ext/pathname.rb @@ -58,9 +58,9 @@ def replace(open_flags_read = ["r"], open_flags_write = ["w"]) } end - BINARY_ENCODING = RUBY_VERSION < "1.9" ? "" : ":ASCII-8BIT" - BINARY_READ_FLAGS = "rb" + BINARY_ENCODING - BINARY_WRITE_FLAGS = "wb" + BINARY_ENCODING + binary_encoding = RUBY_VERSION < "1.9" ? "" : ":ASCII-8BIT" + BINARY_READ_FLAGS = "rb" + binary_encoding + BINARY_WRITE_FLAGS = "wb" + binary_encoding unless method_defined?(:binread) def binread(length = nil, offset = nil) diff --git a/test/test_pathname.rb b/test/test_pathname.rb index 4cfd7bf..a54231e 100644 --- a/test/test_pathname.rb +++ b/test/test_pathname.rb @@ -145,7 +145,7 @@ def test_glob_files if File::ALT_SEPARATOR == "\\" def test_initialize - assert_equal "a/b/c", Pathname("a\\b\\c").to_s + assert_equal Pathname("a/b/c"), Pathname("a\\b\\c") end end @@ -154,8 +154,9 @@ def test_copy_to contents = "abab" source.write(contents) assert(!dest.exist?) - source.copy_to(dest) - assert contents, source.read - assert contents, dest.read + result = source.copy_to(dest) + assert_equal contents, source.read + assert_equal contents, dest.read + assert_equal dest, result end end