Sha256: 019e71917b967d527e06501fc44dcd5abad30f0687f5f34d6591fd7d5e91926a

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'
require 'fileutils'
require 'repo_manager/actions/action_helper'

class Thing
  include ::RepoManager::ActionHelper
end

describe RepoManager::ActionHelper  do

  describe 'relative_path', :posix => true do

    it "should return relative path given an absolute path" do
      thing = Thing.new
      FileUtils.stub!('pwd').and_return '/home/robert/workspace/my_app'
      thing.relative_path('/home/robert/workspace/my_app/photos').should == './photos'
      thing.relative_path('/home/robert/photos').should == '../../photos'
    end

    it "should return relative path given a relative path" do
      thing = Thing.new
      FileUtils.stub!('pwd').and_return '/home/someuser/my_app'
      thing.relative_path('cats/dogs').should == './cats/dogs'
    end

  end

  describe 'relative_path', :windows => true do

    context "on the same drive" do
      it "should return relative path given an absolute path" do
        thing = Thing.new
        FileUtils.stub!('pwd').and_return 'c:/home/robert/workspace/my_app'
        thing.relative_path('c:/home/robert/workspace/my_app/photos').should == './photos'
        thing.relative_path('c:/home/robert/photos').should == '../../photos'
      end
    end

    context "on a different drive" do
      it "should return relative path given an absolute path" do
        thing = Thing.new
        FileUtils.stub!('pwd').and_return 'c:/home/robert/workspace/my_app'
        thing.relative_path('d:/some/path/photos').should == 'd:/some/path/photos'
      end
    end

    it "should return relative path given a relative path" do
      thing = Thing.new
      FileUtils.stub!('pwd').and_return 'c:/home/someuser/my_app'
      thing.relative_path('cats/dogs').should == './cats/dogs'
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
repo_manager-0.7.3 spec/basic_app/actions/action_helper_spec.rb
repo_manager-0.7.2 spec/basic_app/actions/action_helper_spec.rb
repo_manager-0.7.1 spec/basic_app/actions/action_helper_spec.rb