Sha256: ccf03eae14abd2d9ab5960567637b1044be55abf49f536b0d15dba57b6b53f44

Contents?: true

Size: 731 Bytes

Versions: 6

Compression:

Stored size: 731 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe File, ".relative_path" do
  it "should return the relative path between two files" do
    File.relative_path('a/b/c/d.html', 'a/b/d/q.html').should == '../d/q.html'
  end
  
  it "should return the relative path between two directories" do
    File.relative_path('a/b/c/d/', 'a/b/d/').should == '../d'
  end
  
  it "should return only the to file if from file is in the same directory as the to file" do
    File.relative_path('a/b/c/d', 'a/b/c/e').should == 'e'
  end
  
  it "should handle non-normalized paths" do
    File.relative_path('Hello/./I/Am/Fred', 'Hello/Fred').should == '../../Fred'
    File.relative_path('A//B/C', 'Q/X').should == '../../Q/X'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yard-0.2.3.5 spec/core_ext/file_spec.rb
yard-0.2.3.4 spec/core_ext/file_spec.rb
yard-0.2.3.2 spec/core_ext/file_spec.rb
yard-0.2.3.3 spec/core_ext/file_spec.rb
yard-0.2.2 spec/core_ext/file_spec.rb
yard-0.2.3 spec/core_ext/file_spec.rb