Sha256: bad8f394421ed5edaa004aa64787056918af20fac0b5a910c8eca10699a08518

Contents?: true

Size: 1.58 KB

Versions: 54

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

class PathTester
  extend PathResolver
end

describe PathResolver do
  it 'gives a path at the same level as the parent if the url is relative and there is no parent specified' do
    parent_url = 'allo/home.html' 
    url = 'bob.jpg'

    actual = PathTester.translate url, parent_url
    expected = 'allo/bob.jpg'

    actual.should == expected
  end

  it 'absolute url should return a path relative to the root of the app' do
    parent_url = 'allo/home.html'
    url = '/bob.jpg'

    actual = PathTester.translate url, parent_url
    expected = 'bob.jpg'

    actual.should == expected
  end
  
  it "should throw when the parent_url is absolute" do
    parent_url = '/allo/home.html'
    url = '/bob.jpg'

    lambda{ PathTester.translate url, parent_url }.should raise_error   
  end
  
  it "should nest on absolute" do
    parent_url = 'allo/home.html'
    url = '/johnny/cash/likes/women/but/not/bob.jpg'

    actual = PathTester.translate url, parent_url
    expected = 'johnny/cash/likes/women/but/not/bob.jpg'

    actual.should == expected
  end

  it "should nest on relative" do
    parent_url = 'johnny/cash/likes/women/but/not/home.html'
    url = 'wazzo/wazoo/bob.jpg'

    actual = PathTester.translate url, parent_url
    expected = 'johnny/cash/likes/women/but/not/wazzo/wazoo/bob.jpg'

    actual.should == expected
  end

  it "should handle pathname as strings" do
    parent_url = Pathname.new 'allo/home.html' 
    url = Pathname.new 'bob.jpg'

    actual = PathTester.translate url, parent_url
    expected = 'allo/bob.jpg'

    actual.should == expected
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
trackman-0.5.4 spec/paths/pathman_spec.rb
trackman-0.5.3 spec/paths/pathman_spec.rb
trackman-0.5.2 spec/paths/pathman_spec.rb
trackman-0.5.1 spec/paths/pathman_spec.rb
trackman-0.5.0 spec/paths/pathman_spec.rb
trackman-0.4.8 spec/paths/pathman_spec.rb
trackman-0.4.7 spec/paths/pathman_spec.rb
trackman-0.4.6 spec/paths/pathman_spec.rb
trackman-0.4.5 spec/paths/pathman_spec.rb
trackman-0.4.4 spec/paths/pathman_spec.rb
trackman-0.4.3 spec/paths/pathman_spec.rb
trackman-0.4.2 spec/paths/pathman_spec.rb
trackman-0.4.1 spec/paths/pathman_spec.rb
trackman-0.4.0 spec/paths/pathman_spec.rb
trackman-0.3.5 spec/paths/pathman_spec.rb
trackman-0.3.4 spec/paths/pathman_spec.rb
trackman-0.3.2 spec/paths/pathman_spec.rb
trackman-0.3.1 spec/paths/pathman_spec.rb
trackman-0.3.0 spec/paths/pathman_spec.rb
trackman-0.2.90 spec/paths/pathman_spec.rb