Sha256: 0768a518dbdb343b6e6f1bda352346f69a377c1796dea944e80deff88c82c95d

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

class PathTester
  extend Resolver
end

describe Resolver 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

8 entries across 8 versions & 1 rubygems

Version Path
trackman-0.6.3 spec/paths/pathman_spec.rb
trackman-0.6.2 spec/paths/pathman_spec.rb
trackman-0.6.1 spec/paths/pathman_spec.rb
trackman-0.6.0 spec/paths/pathman_spec.rb
trackman-0.5.8 spec/paths/pathman_spec.rb
trackman-0.5.7 spec/paths/pathman_spec.rb
trackman-0.5.6 spec/paths/pathman_spec.rb
trackman-0.5.5 spec/paths/pathman_spec.rb