Sha256: d1da8214da6d57b26660ce81f2ab69d4f734d38e8748b7a6817882ed21572f39
Contents?: true
Size: 1.6 KB
Versions: 10
Compression:
Stored size: 1.6 KB
Contents
######################################################################## # test_clean.rb # # Test suite for the Pathname#clean method. ######################################################################## require 'test-unit' require 'pathname2' class TC_Pathname_Clean < Test::Unit::TestCase def setup @path = Pathname.new("C:\\foo\\..\\bar\\.\\baz") end test "clean basic functionality" do assert_respond_to(@path, :clean) assert_nothing_raised{ @path.clean } assert_kind_of(Pathname, @path.clean) end test "clean returns expected results for unclean paths" do assert_equal("C:\\a\\c", Pathname.new("C:\\a\\.\\b\\..\\c").clean) assert_equal("C:\\a", Pathname.new("C:\\.\\a").clean) assert_equal("C:\\a\\b", Pathname.new("C:\\a\\.\\b").clean) assert_equal("C:\\b", Pathname.new("C:\\a\\..\\b").clean) assert_equal("C:\\a", Pathname.new("C:\\a\\.").clean) assert_equal("C:\\d", Pathname.new("C:\\..\\..\\..\\d").clean) end test "clean returns already clean paths unmodified" do assert_equal("C:\\", Pathname.new("C:\\").clean) assert_equal("C:\\a", Pathname.new("C:\\a").clean) assert_equal("C:\\a\\", Pathname.new("C:\\a\\").clean) assert_equal("\\\\foo\\bar", Pathname.new("\\\\foo\\bar").clean) assert_equal("a", Pathname.new("a").clean) end test "clean returns a slash for . and .." do assert_equal("\\", Pathname.new(".").clean) assert_equal("\\", Pathname.new("..").clean) end test "clean does not modify receiver" do @path.clean assert_equal("C:\\foo\\..\\bar\\.\\baz", @path) end def teardown @path = nil end end
Version data entries
10 entries across 10 versions & 1 rubygems