Sha256: 7f807b41b9fe2cf7c9bddb607c12cc50b808dfe63073bb21b6c06c6ec32ac4f1
Contents?: true
Size: 1.38 KB
Versions: 10
Compression:
Stored size: 1.38 KB
Contents
######################################################################## # test_descend.rb # # Test suite for the Pathname#descend method. ######################################################################## require 'pathname2' require 'test-unit' class TC_Pathname_Descend < Test::Unit::TestCase def setup @path = Pathname.new("C:\\foo\\bar\\baz") end test "descend basic functionality" do assert_respond_to(@path, :descend) assert_nothing_raised{ @path.descend{} } end test "descend works as expected on a standard absolute path" do array = [] @path.descend{ |e| array << e } assert_equal('C:', array[0]) assert_equal('C:\foo', array[1]) assert_equal('C:\foo\bar', array[2]) assert_equal('C:\foo\bar\baz', array[3]) end test "descend works as expected on a UNC path" do array = [] Pathname.new('//foo/bar/baz').descend{ |e| array << e } assert_equal("\\\\foo\\bar", array[0]) assert_equal("\\\\foo\\bar\\baz", array[1]) end test "descend works as expected on a relative path" do array = [] Pathname.new('foo/bar/baz').descend{ |e| array << e } assert_equal('foo', array[0]) assert_equal('foo\bar', array[1]) assert_equal('foo\bar\baz', array[2]) end test "descend does not modify the receiver" do @path.descend{} assert_equal('C:\foo\bar\baz', @path) end def teardown @path = nil end end
Version data entries
10 entries across 10 versions & 1 rubygems