Sha256: 0af17c5ea1c1722df56b01529855924bb88b1d77581144d615bb7ebcb2e00082

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

require 'spidr/extensions/uri'

require 'spec_helper'

describe URI do
  describe "expand_path" do
    it "should preserve single directory paths" do
      URI.expand_path('path').should == 'path'
    end

    it "should preserve trailing '/'" do
      URI.expand_path('test/path/').should == 'test/path/'
    end

    it "should remove multiple '/' characters" do
      URI.expand_path('///test///path///').should == '/test/path/'
    end

    it "should remove '.' directories from the path" do
      URI.expand_path('test/./path').should == 'test/path'
    end

    it "should handle '..' directories properly" do
      URI.expand_path('test/../path').should == 'path'
    end

    it "should limit the number of '..' directories resolved" do
      URI.expand_path('/test/../../../..').should == '/'
    end

    it "should preserve absolute paths" do
      URI.expand_path('/test/path').should == '/test/path'
    end

    it "should preserve the root path" do
      URI.expand_path('/').should == '/'
    end

    it "should default empty paths to the root path" do
      URI.expand_path('').should == '/'
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spidr_epg-1.0.0 spec/extensions/uri_spec.rb
spidr-0.4.1 spec/extensions/uri_spec.rb
spidr-0.4.0 spec/extensions/uri_spec.rb
spidr-0.3.2 spec/extensions/uri_spec.rb
spidr-0.3.1 spec/extensions/uri_spec.rb
spidr-0.3.0 spec/extensions/uri_spec.rb